Docker-Compose
Networking
By default, Docker-Compose will create a new network for the given compose file. You can change the behavior by defining custom networks in your compose file.
Create and assign custom network
… Example:
1
2
3
4
5
6
7
networks:
custom-network:
services:
app:
networks:
- custom-network
Use existing networks
If you want to use an existing Docker network for your compose files, you can add the external: true
parameter in your compose file Example:
1
2
3
networks:
existing-network:
external: true
Volumes
Volumes allow Docker containers to use persistent storage. In a compose file, you can create and map volumes like this:
1
2
3
4
5
6
7
volumes:
my-volume:
services:
app:
volumes:
- my-volume:/path-in-container
These volumes are stored in /var/lib/docker/volumes
.
This post is licensed under CC BY 4.0 by the author.
Comments powered by Disqus.