reclaimed.tech
Containers
Reclaim Cloud specifcs:
Environment = Grouping of containers
Node = Single container
Get a pre-configured container from a registry
Update containers that you are already using
docker pull
The most popular container registry
How do you know what images to pick?
Run a docker container directly from the command line.
There are multiple arguments that can be passed to containers run this way, but too many and this can be a cumbersome way of managing an application.
Run a docker container from the command line by reading directions from a YAML file:
docker-compose.yml
This method makes it easier to manage an application over time, as you can edit the text file to make changes.
Running Docker Containers
You have two main methods:
-d
run the container in the background (daemon mode)
-p
map port 8080 on the host to container port 80
-v
make a volume called nextcloud
to persistently store the contents of /var/www/html
nextcloud
pull the nextcloud
image from dockerhub and run it
docker run
docker run -d -p 8080:80 -v nextcloud:/var/www/html nextcloud
-d
run the container(s) in the background (daemon mode)
ports:
map port 8080 on the host to container port 80
volumes:
make a volume called nextcloud
to persistently store the contents of /var/www/html
image:
pull the nextcloud
image from dockerhub and run it
docker-compose
version: '3.3' services: app: image: nextcloud restart: always ports: - '8080:80' volumes: - 'nextcloud:/var/www/html' volumes: nextcloud:
docker-compose.yml file:
command:
docker-compose up -d
/var/lib/docker/volumes
The persistent storage for a docker container. Anything not located in a docker volume or bind mount gets overwritten when pulling updates or even restarting a container
Configuration options for applications running in Docker. These are added by the developer of the docker container that you have pulled from a registry.
Can be passed via the docker run command, a .env file or as part of a docker-compose file.
A file that tells Docker how to build an image automatically.
A common pattern for a Dockerfile is to ask Docker to pull an image, but then automatically running several other commands inside the container to configure it to your needs.
This is one way that developers make the images that get uploaded to registries like Dockerhub.
Tags track the version of a Docker image that you can pull from a registry. If you do not specify a tag when pulling an image, you will get the image with the "latest" tag each time you pull the image.
Images
Images are versions of a container that you upload to or download from a registry. Containers that you run are built from that image.
docker ps
docker stop CONTAINER_NAME_OR_ID
docker exec -it CONTAINER_NAME_OR_ID bash
docker-compose up -d
docker-compose down
docker-compose logs -f
docker-compose pull
NOTE: all docker-compose
commands must be run from a directory that contains a docker-compose.yml
file