Common commands for docker compose configuration files
Precautions for yaml file format and writing
- Yaml is an intuitive data serialization format with high readability. Similar to the XML Data Description Language, The syntax is much simpler than XML.
- The yaml data structure is represented by indentation. Consecutive items are represented by minus signs. Key-value pairs are separated by colons, arrays are enclosed by brackets, and hash is enclosed by curly brackets..
Considerations for yaml file format:
- 1. Tab key indentation is not supported, and space indentation is required.
- 2. Generally, two spaces are indented at the beginning.
- 3. One space is indented after the character,
# Build the image context path
Build
# Specify the dockefile name
Dockerfile
# From Image
Image
# Build parameters. The parameter specified in dockerfile
ARGs
# Override default commands
Command
# Customize the container name. If the custom name is used, the service cannot be scaled out of 1 container.
Container_name
# Specify the configurations related to deployment and operation. Version 3
Deploy
# Dependencies between services to control the service startup sequence. Normally, the service is started in order.
Depends_on
# Custom DNS server, which can be a single value or list
DNS
# Override entrypoin
Entrypoint
# Add an environment variable from a file, which can be a single value or a list
Env_file
# Add environment variables, which can be arrays or dictionaries. Boolean values are enclosed in quotation marks.
Environment
# Declare the Container Service port
Expose
# Connect to another container
Links
# Connecting containers other than compose
External_links
# Add a host name ing, which is the same as-addhost.
Extra_hosts
# Record the Service Log. Same as-logdriver
Logging
# Network mode, same as-Net
Network_mode
# The network to be added.
Networks
# Specify the static IP address of the container for the service when you join the network
Aliases
Ipv4_address, ipv6_address
# Set the PID mode to the host PID mode to share the PID address space with the host. PID: "host"
PID
# Expose the port, which is the same as-P. But the port is no less than 60
Port
# Set Kernel Parameters in the container, which can be arrays or dictionaries.
Sysctl
# Overwrite the container's default ulimits
Ulimits
# Mount a directory or an existing data volume container to the container
Volume
# No, always | onfailure | unless-stopped
Restart
# Host Name
Hostname
# Working directory
Working_di
More commands:Https://docs.docker.com/compose/compose-file/compose-file-v2/
Common commands for docker compose configuration files