I am running a docker container ( dind
) from jenkins execute shell
CONTAINER_ID="$(sudo docker run --privileged -i -d jpetazzo/dind)"
To execute docker commands inside container I get into container shell
sudo docker exec -it --privileged ${CONTAINER_ID} bash
and than I am trying to execute these commands inside dind
container.
sudo docker pull hubuser/hello-world
sudo docker run hubuser/hello-world
sudo docker tag imageId hubuser/hello-world:123
sudo docker login --username=hubuser --password=password
sudo docker push hubuser/hello-world
All of these 7 commands I have written in jenkins execute shell. Below given 5 commands are executing outside dind
container, not inside. If I am trying from terminal than it is attaching to the container shell and executing properly. I want to execute them inside container but from jenkins. I also tried adding exec
before every command like this:
sudo docker exec -it --privileged ${CONTAINER_ID} sudo docker pull hubuser/hello-world
sudo docker exec -it --privileged ${CONTAINER_ID} sudo docker run hubuser/hello-world
and so on. This executes commands inside dind
container but all commands executes in parallel, so before pulling and running the hello-world
image, it tries to tag it and push it. There it is not finding any hello-world
image to tag and it does't do anything.
I want all my below 5 commands to execute serially inside dind
container, that too from jenkins execute shell.
The title of your post is "how to ssh into running docker". I just want to point out this article, wrote by a Docker engineer: If you run SSHD in your Docker containers, you're doing it wrong!
After I read your post, that is not treating issue with ssh, I just thought about: why not execute a bash-script that does sequentially what you wanted to?
I'm not sure if I understood well btw, is Jenkins inside a docker? Are you running a docker in a docker?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.