Docker Compose II
I. Define the Project
II. Create a docker-compose.yml file
III. Structure of docker-compose.yml
version: '3'
services:
web:
# /path/to/dockerfile/
build:?.
volumes:
??????-?"/your_code/:/project_code"
links:
??????-?"db:backenddb"
db:
image: mysql
ports:
- "3306:3306"
environment:
- MYSQL_ROOT_PASSWORD=password
- MYSQL_USER=user
- MYSQL_PASSWORD=password
volumes:
??????-?"/db/init.sql:/init.sql"
??
领英推荐
IV. Build and run your app with Compose
Run the below commands from your project directory. You can start up your application using `docker-compose up` commands. If our compose file has a different name than the default one (docker-compose.yml), we can add -f to specify an alternate filename.
docker-compose up < Build and run your application >
docker-compose up -d < Build and run your application in detached mode >
docker-compose -f compose-file.yml up < For custom file name >
V. Docker Compose commands
Refer Docker Compose articles for different docker compose commands.
For more sample docker compose application check official: https://docs.docker.com/samples/#sample-applications
PS: Please don't copy-paste this article. If you find it useful please feel free to share it, and yes don't forget to give credits.