Skip to content

Instantly share code, notes, and snippets.

@chunter
Created June 15, 2017 07:54
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chunter/1834f08212f023e00326f4ef7c73ba5c to your computer and use it in GitHub Desktop.
Save chunter/1834f08212f023e00326f4ef7c73ba5c to your computer and use it in GitHub Desktop.
Simple Docker Installation
This is to help familiarise with Docker and how to install, run and delete containers. It doesn't do anything useful beyond that.
Install Docker
- Search for 'Docker for Windows' (https://docs.docker.com/docker-for-windows/install/)
- Install from the downloaded .msi
Check installation:
- in Git Bash (may need to run as an administrator):
- 'docker -v'
- 'docker-machine -v'
- 'docker-compose -v'
Create a default machine:
- 'docker-machine create --drive hyperv default'
- if this gets stuck then create a new virtual switch within Hyper-V (detailed below)
- check it has installed ok by typing 'docker ps' & something should appear
Use Hyper-V manager to create a virtual switch (allows the virtual machine access to the wifi):
- click on machine name 'IMT-xxxxx'
- click on 'default'
- click on 'virtual switch manager'
- click on 'DockerNAT'
- choose 'external network'
- choose the wireless from the dropdown
- tick the box underneath
- tick 'apply'
List machines:
- 'docker-machine ls'
Stop machine:
- 'docker-machine stop default'
Find images we have:
- 'docker images'
Pull hello-world image from https://hub.docker.com/
- 'docker pull hello-world'
- private repositories - need to use the registry address as part of the pull
Create a container to run 'hello-world':
- 'docker run -d hello-world'
Check it exists & has run:
- 'docker ps -a' - the '-a' shows all the instances that have run in the past
Show what is currently running:
- 'docker ps'
Run and keep live:
- 'docker run hello-world'
(A message should appear to show the installation is working)
Get ubuntu image
- 'docker run ubuntu bash'
- 'docker ps -a' will show that ubuntu has downloaded
A container is a instance of the image - which can be running or stopped. Many container instances can be run from one image.
Run bash in an ubuntu container:
- 'docker run -it ubuntu bash'
- 'ls'
- 'exit' to return to the command window from ubuntu
Run and keep the container running (example):
- 'docker run -d ubuntu tail -f dev/null'
- '-d' means run in the background, don't print to this window
- 'tail -f dev/null' - is an ubuntu command - logs to the window the contents of the file dev/null
list the container ids
- 'docker ps -aq'
Remove all containers in the list
- 'docker rm -vf $(docker ps -aq)'
- docker remove version force (if running) - takes a list of ids and removes them all
Remove all the images
- 'docker rmi -f $(docker images -aq)'
- but it wont delete any currently being used by a container
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment