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?
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.
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.
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.
You just have to start and attach a container using:
docker start -i #ContainerID
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With