Create yml using docker compose

Source: Internet
Author: User
Tags docker ps docker compose

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.