2

How can start a specific container created linked with my image? exec command? or another command?

And: Supposed to have more container to refer single image, what is the command to start a specific container with network?
The command docker run can start only image with network (--net=host for example), but I don't want run images, I want to run a specific container linked with my images. How can I do that?

1 Answer 1

0

docker exec is purely for debugging purposing.
docker run is what you want to start a container based on an image.

When you run a container, you do so based on an image and parameters like network.
Example:

docker run -itd --network=multi-host-network busybox

That being said, an existing running container can be attached to a network with the command docker network connect

docker network connect [OPTIONS] NETWORK CONTAINER

Do a docker ps to get the ID or tag of your container.
Example:

docker network connect multi-host-network container1

Regarding the difference between image and containers:

https://blog.newrelic.com/wp-content/uploads/docker-image-vs-containers.jpg
(Source: "The Modern Developer Workstation on MacOS with Docker", by Clay Smith)

9
  • you said " docker run -itd --network=multi-host-network busybox " , but busybox is an image.. i've created more container with myimage for example. Container1 --> myImage.. Container2-> myImage.. I want to start Container1, not run myImage. maybe i explained myself wrong
    – Riccardo
    Commented Jun 10, 2017 at 10:12
  • Contaier1 is already started. You can attached it to the network with the last command I mention in the answer.
    – VonC
    Commented Jun 10, 2017 at 10:14
  • ok, i got it.. but command "run" start myImage with generic container id? in your example "busybox" is an image, can i insert a specific container id? I Would start a specific container linked to myImage and not run myImage
    – Riccardo
    Commented Jun 10, 2017 at 10:18
  • No, you can start it with a tag of your choosing: the doc is quite detailed on that.
    – VonC
    Commented Jun 10, 2017 at 10:27
  • it's not clear. Could you do an example? i've an image "myImage" and 2 container "container1 and container2" linked to myImage. I would to start container1 or container2 and use filesystem (myImage). or maybe i can create ONLY one container for Image.. I'm confused
    – Riccardo
    Commented Jun 10, 2017 at 12:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.