- Layer: Files generated from running some command, also called intermediate images. Reused by multiple images to reduce image and size.
- Image: A docker container image is created using a dockerfile (ie. build). Every line in a dockerfile will create a layer.
- Container: an instance of an (read-only) image.
- Docker Client: the CLI tool that allows the user to interact with the Docker Server.
- Docker Server: aka Docker Daemon, the background service running on the host that manages the building, running and distributing Docker containers.
# Use an existing image as a base
FROM alpine
# Download and install a dependency
RUN apk add --update redis
# Tell an image what to do when it starts as a container
CMD ["redis-server"]
Then build its image: docker build .
And run it: docker run -p 8080:8080 id-given-upon-build-completion
Simple Example:
version: '3'
services:
redis-server:
image: 'redis'
node-app:
restart: on-failure
build: .
ports:
- "4001:8081"