Docker Compose basic use - use Compose to start Tomcat as an example

Scenes

Compose installed on Docker-Compose Introduction and Ubuntu Server:

https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/100902301

On the basis of the above Compose achieve a successful installation, the use Compose to start the project.

achieve

First came to / usr / local directory under, the new docker directory, enter docker directory, then create tomcat directory, enter tomcat directory.

 

 

Then enter:

vi Docker-compose.yml

Create a new profile.

 

 

Then copy the following into yml profile.

version: '3'
services:

  tomcat:
    restart: always
    image: tomcat
    container_name: tomcat
    ports:
      - 8080:8080

 

Note:

1. In this profile can only use the space, you can not use the Tab key.

2.tomcat on behalf of the service name, restart representatives boot from the start, Imge on behalf of a mirror, container_name representatives containers, ports on behalf of the port, host port on the left, the right container ports,

Open multiple ports.

After copying shift + Ins paste in vi mode, and then press the ESC, and then enter: wq!

Save and exit.

 

 

Compose run the project:

docker-compose up

Open the browser, type:

ip:8080

 

 

Note:

docker-compose the best execution command in the directory of docker-compose.yml.

If you want to change the path, then use

docker-compose -f path

other:

Stop Tomcat using ctrl + c

docker ps -a

View container has been terminated, and how to remove it

docker-compose dowm

This command will stop the command to start up the container and remove network

Guardian state operation

docker-compose up -d

View Log

docker-compose logs tomcat

 

Guess you like

Origin www.cnblogs.com/badaoliumangqizhi/p/11530695.html