/ docker

Docker Basics

1. Install (Ubuntu 16.04)

For other distributions/OSes: [Official Installation Instructions](https://www.docker.com/community-edition)

sudo apt update
sudo apt install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu xenial stable"
sudo apt update
sudo apt install docker-ce

2. Download Image

sudo docker pull <image-name>

sudo docker pull ubuntu

List Installed Images

sudo docker images

3. Create and Run Container (image will also be automatically downloaded)

sudo docker run <flags/options> <image-name>

sudo docker run -dit --name ubuntu_container -p 80:80 ubuntu

List Running Containers

sudo docker ps

List All Containers (Running and Stopped)

sudo docker ps -a

Stop Running Container

sudo docker stop ubuntu_container

Start Stopped Container

sudo docker start ubuntu_container

Login to Running Container's Terminal

sudo docker exec -it ubuntu_container