How to start docker image

王林
Release: 2020-04-14 11:47:36
Original
6997 people have browsed it

How to start docker image

1. Docker run startup

--env-file means loading environment variables from a file. The file format is key=value, one per line. Variable;

-v means to mount the files on the host into the image. The front of the colon indicates the host file path, and the following indicates the image file path. Absolute paths must be used;

- p means mapping port 8080 in the image to port 8083 on the host, and 10.142.8.12 represents the host IP;

docker run -it --env-file ./run/hrms.env -v /opt/hrms/hrms/hrms:/opt/hrms/hrms -p 10.142.8.12:8083:8080 55ad68601db
Copy after login

2. Docker-compose startup

docker-compose is one of the three docker musketeers. It is a plug-in specifically used to start images. It can be installed through pip install docker-compose.

You can create a new folder with the following directory structure as the startup folder of the image:

How to start docker image

Write the docker-compose.yml file:

version: '2.0' services: web: image: hrms:v1.2 restart: always ports: - "8083:8080" env_file: - ./hrms.env volumes: - /opt/hrms/logs/:/opt/hrms/logs/
Copy after login

Startup:

Switch to the directory where docker-compose.yml is located and execute:

docker-compose up
Copy after login

to start the image.

Recommended tutorial:docker tutorial

The above is the detailed content of How to start docker image. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!