----------------------------------------------------------------------
References
----------------------------------------------------------------------
Docker Engine -- runtime and ops https://docs.docker.com/engine/
Create Docker Containers -- build your own https://docs.docker.com/build/
Orchestrate Containers -- combine containers https://docs.docker.com/compose/
----------------------------------------------------------------------
Basic Docker - Overview
----------------------------------------------------------------------
Basic Docker Architecture
- Image as container - Binary images of s/w systems published as Containers
- Versioned - Containers are versioned
- Decentralized - Your server downloads/stores containers and their parents...warning, this gets large!
Basic Docker Lifecycle
- Pull containers to use or extend
- Run containers and expose local resources to them
- Extend existing containers to create custom run-anywhere binaries
----------------------------------------------------------------------
Basic Docker - Setup
----------------------------------------------------------------------
Install
sudo apt install docker.io
sudo apt install docker-compose
Running without sudo
Assign your user into the docker group. Add group if necessary.
sudo groupadd docker
sudo usermod -a -G docker myuser
# refresh groups or restart server
Other post-install tasks
See https://docs.docker.com/install/linux/linux-postinstall/
Configure - start on boot
On CentOS:
sudo systemctl [enable|disable] docker
----------------------------------------------------------------------
Docker service
----------------------------------------------------------------------
sudo service docker start
Start/Stop Docker Service
Debian:
CentOS:
sudo systemctl [start|stop] docker
Test Docker Service
sudo docker run hello-world
----------------------------------------------------------------------
Managing Images
----------------------------------------------------------------------
List all Images
docker images
docker image inspect <imageid>
docker tag <imageid> <alias>
Remove Image (untagging)
docker rmi <alias>
Move docker image location off to another drive (for large files)
sudo service docker stop
ps faux|grep docker
sudo ls /var/lib/docker
mv /var/lib/docker <new location>
sudo service docker start
Running Containers
----------------------------------------------------------------------
docker run -it [-d] [--rm] [--network <name>] <image_id>
-d starts detached (daemon)
--rm removes on exit
--network network name to use (see `docker network ls`)
Retain image changes
docker commit <container_id> <group>/<alias>
Attach and execute shell
docker exec -it <container_id> bash
docker build . -t <alias>
docker attach <container_id>
Creating Images
----------------------------------------------------------------------
Create a Dockerfile with a base image
Docker and Docker-Compose Runtime
----------------------------------------------------------------------
Start docker-compose containers
docker-compose up -d