Containers How To
How to install Docker (Windows Platform)
- Login to the machine using privileged account
- Download the latest Docker build from:
How to install Docker (Ubuntu)
- Login to the machine using privileged account
- Follow the instructions below:
How to install Docker (RHEL / CentOS)
- Login to the machine using privileged account
- Follow the instructions below:
Common Docker commands
- Check the Docker version:
- docker --version
• Pull and run “hello-world” image from Docker hub: docker run hello-world • List images: docker images • List all images: docker image ls • Pull an image from Docker hub: docker image pull alpine • Remove Docker image (by image name) from the local machine: docker image rm nginx • List all containers: docker container ls --all • List active containers: docker ps • List all container processes (same as docker container ls command) docker ps --all • Pull nginx web server from Docker hub and run it on port 80 on the local machine: docker run --detach --publish 80:80 --name webserver nginx Note: Open browser and enter the URL http://localhost to make sure the web server is working • Start a container in the background: docker run -d jenkins • Start an interactive shell command from a container (by image name): docker run -it nginx bash • Mount a folder from the local machine into a docker container, and map port 8080 locally to port 80 on the container (container name nginx): docker run -v /full/path/to/html/directory:/usr/share/nginx/html:ro -p 8080:80 -d nginx • Stop running container (by container name) from the local machine: docker container stop webserver • Start (a stopped) docker container (by container name) on the local machine: docker container start webserver • Kill all running containers: docker kill $(docker ps -q) • Remove all stopped containers: docker rm $(docker ps -a -q) • Remove container (by container name) from the local machine: docker container rm webserver • View logs from a running container (by container name): docker container logs webserver • Show live logs of running container: docker logs -f c7337 • View top processes inside a container (by container name): docker container top webserver • Show exposed ports of a container: docker port c7337