Docker handson- The ops perspective
- Check docker version
docker version - Check for existing docker images
docker images - Copy new image onto your “docker host”
docker pull <image-name> - Start a container from the pulled image
docker run --name <container-name> -d -p 8080:80 <image-name>-d to start container in background -p 8080:80 Map port 80 inside container with port 8080 inside docker host
- Check which containers are running
docker ps - Execute a command inside the container
docker exec -it <container-name bashHere we can run a limited set of linux command only as most containers only ship with essential apps and tools to keep them small.
- Exit from container shell
exit - Delete the container and image(cleanup)
docker stop <container-name> docker ps -a docker rm <container-name> docker ps -aThe -a option of the ps command shows the container entry after stopping it. The same entry disappears once you remove it using the docker rm command.
This is a typical sequence of commands executed in a docker container lifecycle from an operational engineer’s perspective