Skip to content

Instantly share code, notes, and snippets.

@mnguyenngo
Last active August 24, 2018 20:21
Show Gist options
  • Save mnguyenngo/95f66467865883aa9dcbc5569d230d5e to your computer and use it in GitHub Desktop.
Save mnguyenngo/95f66467865883aa9dcbc5569d230d5e to your computer and use it in GitHub Desktop.
Typical workflow for starting docker on a new VM
# install docker
sudo apt-get install docker
# the above command did not work (8/24/18); try the command below
sudo curl -sSL https://get.docker.com/ | sh
# pull nginx image
sudo docker pull nginx:1.10.0
sudo docker images
# verify the versions match
sudo dpkg -l | grep nginx
# if versions do not match, update the VM instance
sudo apt-get update
sudo apt-get install nginx
# run an instance of nginx (this can be executed multiple times to create multiple instances)
sudo docker run -d nginx:1.10.0
# check if it is up
sudo docker ps
# check how many instances are running
sudo ps aux | grep nginx
# show all (-a) instances running and only return numeric id (-q)
sudo docker ps -aq
# inspect an individual container
sudo docker inspect <cid>
# this will return a JSON object describing the container
# you can copy the IP address run curl to communicate with the container
curl 172.17.0.3
# this will return the default nginx page
# run the following to return the name and IP address of each container
sudo docker inspect -f '{{.Name}} - {{.NetworkSettings.IPAddress }}' $(sudo docker ps -aq)
# stop a container (<cid> is the container id)
sudo docker stop <cid>
# to remove all containers
sudo docker stop $(sudo docker ps -aq)
# remove a docker container from the system
sudo docker rm <cid>
# to remove all containers
sudo docker rm $(sudo docker ps -aq)
# Reference: Kubernetes Udacity Course (https://classroom.udacity.com/courses/ud615)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment