Docker container will automatically stop after “docker run -d”

The centos dockerfile has a default command bash. That means, when run in background (-d), the shell exits immediately. Update 2017 More recent versions of docker authorize to run a container both in detached mode and in foreground mode (-t, -i or -it) In that case, you don’t need any additional command and this is … Read more

Change directory command in Docker?

You can run a script, or a more complex parameter to the RUN. Here is an example from a Dockerfile I’ve downloaded to look at previously: Because of the use of ‘&&’, it will only get to the final ‘pip install’ command if all the previous commands have succeeded. In fact, since every RUN creates … Read more

kubectl get pods shows ErrImagePull

Reason This is because it can’t download the docker image defined in your pod definition file. By default it downloads required images from DockerHub. Way 1 So after creating your my-first-image:3.0.0 image you have to publish it at DockerHub. For that create an account at DockerHub and login from terminal using login command After successful login, rebuild your docker image … Read more

How to remove old Docker containers

Since Docker 1.13.x you can use Docker container prune: This will remove all stopped containers and should work on all platforms the same way. There is also a Docker system prune: which will clean up all unused containers, networks, images (both dangling and unreferenced), and optionally, volumes, in one command. For older Docker versions, you can string Docker commands … Read more