There's a lot of depth to be found in docker.
To truly utilize docker you want to use docker-compose. But often the important part is knowing how to specify information, this is where the cheat sheet comes into play.
Caution
To keep oversight i recommand to use an number to identify containers like: 001-NAME
.
Note
Its very basic...
Details
+ version: ${VERSION}
+
+ services:
+ container:
+ container_name: ${NAME}
+ restart: unless-stopped
+ image: ${IMAGE}:${IMAGE_VERSION}
+ ports:
+ - ${PORT}:${PORT}
Variables
Variable | Example | Explanation |
---|---|---|
VERSION |
2.8 | This indicates the docker-compose version. |
NAME |
container | Specifies the name of the container. |
IMAGE |
hello-world | What image the container uses. |
IMAGE_VERSION |
latest | The version of the specified image, can always use "latest". |
PORT |
80 | To enable network traffic over certain ports use this. |
Note
Its sending logs now
Details
version: ${VERSION}
services:
container:
container_name: ${NAME}
restart: unless-stopped
image: ${IMAGE}:${IMAGE_VERSION}
ports:
- ${PORT}:${PORT}
+ logging:
+ driver: syslog
+ options:
+ syslog-address: "udp://${LOG_HOST}:${LOG_PORT}"
+ tag: ${NAME}
Variables
Variable | Example | Explanation |
---|---|---|
LOG_HOST |
IP-ADDRESS | The ip-address of the syslog server. |
LOG_PORT |
5514 | Port on which the applciation will send logs. |
Note
Its connected!
Details
version: ${VERSION}
services:
container:
container_name: ${NAME}
restart: unless-stopped
image: ${IMAGE}:${VERSION}
ports:
- ${PORT}:${PORT}
logging:
driver: syslog
options:
syslog-address: "udp://${LOG_HOST}:${LOG_PORT}"
tag: ${NAME}
+ networks:
+ logging-network:
+ ipv4_address: ${IP_ADDRESS}
+ gateway: ${GATEWAY_ADDRESS}
+ dns:
+ - ${DNS}
Variables
Variable | Explanation |
---|---|
IP_ADDRESS |
ip-address of the container, remove to use first available. |
GATEWAY_ADDRESS |
Gateway of the network, remove to use default. |
DNS |
Set a custom DNS server for this specific container. |