Docker - basics
The concept of storing things in containers goes way back to Genesis, but the use of containers for easily deploying applications is new. One of these new containerization platforms is Docker, and this blog post is a collection of setup and config notes I like to refer to when working with it.
Install
Windows 10
See https://docs.docker.com/docker-for-windows/
Linux Ubuntu
Install Docker Engine and Docker Compose separately:
See https://docs.docker.com/engine/install/ubuntu/
See https://docs.docker.com/compose/install/
Commands
Commands that can be run from Bash or PowerShell.
Help
<cmd> --help
<cmd> --version
Pull
Get the latest image of Ubuntu server off of Docker Hubdocker pull ubuntu:latest
Get the a specific version of Ubuntu server off of Docker Hub by tag namedocker pull ubuntu:18.04
Run
docker run hello-world
docker run --interactive --tty ubuntu bash
docker run --detach --publish 80:80 --name webserver nginx
docker run -p 8983:8983 -t solr
Name a container and run it in detached modedocker run -p 8983:8983 -t solr --name solr -d
Images
List imagesdocker images
docker image ls
List images without a tag namedocker images -f “dangling=true” -q
Remove imagedocker image rm wordpress:latest php:latest
docker image prune -a
Volumes
List volumesdocker volume
Remove volumesdocker volume prune
Networks
List networksdocker network
Remove networksdocker network prune
Containers
List containersdocker ps
docker container ls
docker container ls --all
docker ps -aq
Stop containersdocker container stop webserver
docker stop $(docker ps -aq)
sudo docker stop $(sudo docker ps -aq)
Remove containersdocker container rm webserver laughing_kowalevski relaxed_sammet
docker rmi -f c0fdfb66599d
docker rm $(docker ps -aq)
sudo docker rm $(sudo docker ps -aq)
Exec
Access bash shell of Docker appdocker exec -it appname bash
Build
See https://docs.docker.com/engine/reference/commandline/build/
Commit
Commit a build to Docker Hub Repositorydocker commit df75aa301d62 ubuntu:18.04vim
Compose
docker-compose up -d
docker-compose --verbose up