Install Docker on VM Download Image and Run Container

How to Install Docker on VM Machine | Use Docker pull to download Docker Image and how to run Container.

Create a VM Instance like Docker.

Install Docker

Run below commands

After installation, check the version

docker --version

Post-installation steps

Add your current user to the docker group to allow access to docker commands:

sudo usermod -a -G docker $USER

Logout from the terminal and login in the user again:

exit

Use docker pull to download docker images on this server:

docker pull nginx

Use docker run to run the nginx container using this image. Use the below parameters for the container:

  • i. Name: mynginx
  • ii. Host port: 80
  • iii. Container port: 80
  • iv. Should run in detach mode

command

docker run -ti -d --name mynginx -p 80:80 nginx

Login to the mynginx container and check whether the nginx process is running or not. Ideally, it should be running:

docker exec -ti mynginx bash

Install process to run the ps command inside the container.

Command

apt-get update && apt-get install procps

Check if nginx is accessible on http://<Server_Pubilc_IP>:80 and you see below page:

nginx