pods #44681
Replies: 3 comments 1 reply
-
Effectively, a "pod" is a set of containers that have share namespaces; kubernetes uses a "pause" container to set up the initial namespaces, and then other containers join those namespaces to form a "pod". A "somewhat" equivalent for that would be like this; # create the pause container
docker run -dit --name pause_container --ipc=shareable busybox
# then create other container(s) to join it
docker run -d --name container_one \
--ipc=container:pause_container \
--network=container:pause_container \
--pid=container:pause_container \
--volumes-from=pause_container \
nginx:alpine After the above both containers share various namespaces, and effectively are a "pod"; docker exec -it container_one ps aux
PID USER TIME COMMAND
1 root 0:00 sh
7 root 0:00 nginx: master process nginx -g daemon off;
36 nginx 0:00 nginx: worker process
37 nginx 0:00 nginx: worker process
38 nginx 0:00 nginx: worker process
39 nginx 0:00 nginx: worker process
40 nginx 0:00 nginx: worker process
54 root 0:00 ps aux
docker exec -it pause_container ps aux
PID USER TIME COMMAND
1 root 0:00 sh
7 root 0:00 nginx: master process nginx -g daemon off;
36 101 0:00 nginx: worker process
37 101 0:00 nginx: worker process
38 101 0:00 nginx: worker process
39 101 0:00 nginx: worker process
40 101 0:00 nginx: worker process
48 root 0:00 ps aux And (for example) you can access the nginx on localhost from either container; docker exec -it container_one sh -c 'wget -q -O- localhost | grep Welcome'
<title>Welcome to nginx!</title>
<h1>Welcome to nginx!</h1> However, the docker daemon itself does not have a "pod" API; if you must have the "exact" equivalent of what Kubernetes does, you could have a look at https://github.com/Mirantis/cri-dockerd, which implements the Kubernetes CRI API for the Docker Daemon. |
Beta Was this translation helpful? Give feedback.
-
I think I'm a little confused about my real need How do I do this with golang code? |
Beta Was this translation helpful? Give feedback.
-
The idea of the project is not to rewrite docker compose. The idea of the project is to make a chaos testing tool aimed at developing microservices. This is the third version of the tool, as the previous version allowed many configurations and was complicated to use. The basic idea is to allow writing a test code to run on the developer's machine and to allow a small integration test, where the containers behave randomly, stopping, pausing, changing the IP address, and with this, allowing the developer to know how your microservice behaves. For example, if the text "panic:" appears in the container's standard output, the container's standard output is saved on the host computer, in a folder named "bug", thus allowing a later analysis of the problem. My current problem, is that polar project, an alternative to kafka written in golang, was made for kubernetes and I have no idea how to group all instances of polar project into a single block and then connect to it by just passing a single block address. For example, when I connect to the address polar://polar-service, it should connect to the three instances of polar, that is, polar://polar-container-0;polar-container-1;polar-container-2 I'm lost on how to do this without using kubernetes thaJeztah, thank you very much for your help |
Beta Was this translation helpful? Give feedback.
-
I'm creating a framework for chaos test for microservices and I need to group the containers in a pod, k8s style, but I have no idea how to do this.
In the example below, it creates three
nats
instances and leaves them running for 60 minutes without doing anything else.In the example below, I make a clone of the polar project:
Is there any example of how to group the containers in pods, k8s style?
Beta Was this translation helpful? Give feedback.
All reactions