Create yml using docker compose
The format version of The docker compose file must correspond to the docker version, docker compose command docker compose build which can be found on the official website.
Search address:Https://docs.docker.com/compose/compose-file/compose-file-v2/#compose-and-docker-compatibility-matrix
1. Create the compose-test directory, enter the directory, install docker compose and then change the directory to create a file
mkdir compose-test;cd compose
2. Create a constructor
Vim docker-compose.yml.
# Current docker compose version: '3' # container group services: # image Container Service logo Web: docker compose volumes # specify the directory for building the image context, ".docker compose up "Current Directory build :. # ing container port ports:-"8888: 80"
3. Create a dockerfile
Vim dockerfile
# Start image centos: 6 from centos: 6 # Note maintenance personnel maintainer lizhenliang # Run the following command: install the relevant software run Yum install-y httpd PHP-Gd PHP-mysql # Run the following command: Modify the test page run echo "<? PHP phpinfo ()?> ">/Var/www/html/index. PHP # Run the command: start the service cmd ["/usr/sbin/httpd", "-d", "foreground"] # Set port to 80 expose 80
Note: The command must enter the specified path to take effect.
Note: The generated container name is named after the directory name, and the image container identifier is named after the downbars.
4. Execute the docker-compose.yml to execute the command
# The compose command specifies the yml file docker-Compose up
# View build container activation compose command: docker-Compose PS
# Docker command: docker PS
Test Access:Http: // 192.168.1.77: 8888/
Create yml using docker compose