![]()
Installing
You can try install docker compose in two method, apt package managing or manually. Read more at
- Install the Compose plugin (Recommended)
- Install Compose standalone
Use apt package
sudo apt install docker-compose-plugin -yManually download
- To download and install the Compose CLI plugin, run
DOCKER_CONFIG=${DOCKER_CONFIG:-$HOME/.docker}
mkdir -p $DOCKER_CONFIG/cli-plugins
curl -SL https://github.com/docker/compose/releases/download/v2.29.1/docker-compose-linux-x86_64 -o $DOCKER_CONFIG/cli-plugins/docker-compose- Apply executable permissions to the binary
chmod +x $DOCKER_CONFIG/cli-plugins/docker-composeDocumentations
Info
With
docker-compose, you can find and explore more about this technicals with documentation in details, itβs kinda sophisticated, to become more familiar, you should double-check them
Basic command
up and stop command which commonly use to bring up and down the bunch of container inside compose file
# Up command (With out build)
docker-compose -p nameproject -f /locate/your/docker/compose --no-build up -d
# Up command (With build)
docker-compose -p nameproject -f /locate/your/docker/compose --build up -d
# Up command (with specify target service)
docker-compose -p nameproject -f /locate/your/docker/compose up -d yourservice
# Down command
docker-compose -p nameproject -f /locate/your/docker/compose down Common options often use with compose, like
-p: set project name, represent your container name with service in compose file, example:next-application-f: specify with compose file in use for execute with command
Note special Key in compose
Use host network to use driver of local interface,
Use when you want to call via DNS on different network with your eth interface
Documentation: Accessing Host Services from Docker Containers
services:
application:
extra_hosts:
- "host.docker.internal:host-gateway"Select your network with external
networks:
wkernet:
driver: overlay
external: trueUpdate compose
Documentation
Info
You can hand-on with compose via update the container inside stack to new version by trying pull and up again
If you have new version of images inside one of container, you can try to update that via
# You can specific services name or pull all of container
docker compose -f /file/compose -p name-stack pull <services-name>
# Try to restart containers in stack with new image
docker compose -f /file/compose -p name-stack up -d <services-name>Troubleshoot
Not supported URL scheme http+docker
Link issue: Bug - Breaks with requests 2.32.0: Not supported URL scheme http+docker
If you meet this problem, you can try to reinstall or downgrade version of requests package inside your host because docker-compose will use requests for this URL Scheme
# Python < 3.12
pip install requests==2.31.0
# Python >= 3.12
pip install requests==2.31.0 --break-system-packages