Containers How To: Difference between revisions

From PUBLIC-WIKI
Jump to navigation Jump to search
(Created page with "== How to install Docker (Windows Platform) == * Login to the machine using privileged account * Download the latest Docker build from: : https://download.docker.com/win/edge/...")
 
No edit summary
Line 3: Line 3:
* Download the latest Docker build from:
* Download the latest Docker build from:
: https://download.docker.com/win/edge/Docker%20Desktop%20Installer.exe
: https://download.docker.com/win/edge/Docker%20Desktop%20Installer.exe
== How to install Docker (Ubuntu) ==
* Login to the machine using privileged account
* Follow the instructions below:
: https://docs.docker.com/install/linux/docker-ce/ubuntu/
== How to install Docker (RHEL / CentOS) ==
* Login to the machine using privileged account
* Follow the instructions below:
: https://docs.docker.com/install/linux/docker-ce/centos/
== 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

Revision as of 16:48, 10 June 2019

How to install Docker (Windows Platform)

  • Login to the machine using privileged account
  • Download the latest Docker build from:
https://download.docker.com/win/edge/Docker%20Desktop%20Installer.exe

How to install Docker (Ubuntu)

  • Login to the machine using privileged account
  • Follow the instructions below:
https://docs.docker.com/install/linux/docker-ce/ubuntu/

How to install Docker (RHEL / CentOS)

  • Login to the machine using privileged account
  • Follow the instructions below:
https://docs.docker.com/install/linux/docker-ce/centos/

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