Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run the latest docker container I created?

Tags:

docker

When I'm debugging my Dockerfile, y constantly need to run these two commands:

$ docker build -t myuser/myapp:mytag - < myapp.docker # to create the container
$ docker run -i -t myuser/myapp:mytag /bin/bash       # to enter the container and see what's going on when something went wrong

("mytag" is usually something like "production", "testing", or "development". Not sure if I'm supposed to use tags this way)

But now the second command doesn't seem to work anymore: it's starting an old container. If I list all the containers with $ docker images, I see my tagged container in the 3rd place, and other untagged containers before it. If I use the ID of the 1st container it works fine, but it will be annoying to do it that way, I will have to search for its ID every time.

What am I doing wrong?

like image 808
ChocoDeveloper Avatar asked Mar 17 '14 00:03

ChocoDeveloper


People also ask

How do I run an existing docker container?

You can also use the -w (workdir) flag along with the Docker exec command to specify the path of the directory where you want to execute the command inside the container. If you want to access the bash of a container running in background mode, you can use the -it options and provide the /bin/bash command.

How do I update a docker container?

To update to a newer image, you first need to pull the new version. Run the docker pull command followed by a colon and the name and the tag of the newer image: the name and tag that you took note of previously.

Does docker run pull the latest image?

docker pull will always contact the registry and get an updated image. Try, for instance, docker pull ubuntu:18.04 if you have it locally and haven't pulled it recently.


1 Answers

You just have to start and attach a container using:

docker start -i #ContainerID
like image 104
Anaderi Avatar answered Nov 13 '22 13:11

Anaderi