To run a container using an image ๐
docker run <image name>
example: docker run hello-world
Override the default command for a container ๐
docker run <image name> command
example: docker run busybox ls
Show running containers ๐
docker ps
docker ps --all
This will list all the containers that were ever created on your machine.
Restart stopped containers ๐
docker start <container id>
example:
run docker ps –all to get the list of containers
copy the container id of the stopped container (It will have a status as exited) that you want to restart.
It will start the container and use the optional -a flag to log the default output of that container (In the above case it’s ping pixxstudios.com)
Remove stopped containers ๐
docker system prune
Get logs from a container ๐
docker logs <container id>
Stopping a container ๐
docker stop <container id>
Give container 10 seconds to wrap up whatever its doing and then stop the container.
docker kill <container id>
Just stop whatever process is running in the container immediately and then stop the container itself.