From 088bf8c60741517635447ccc6a2df9ce22aac606 Mon Sep 17 00:00:00 2001 From: "13621160019@163.com" <13621160019@163.com> Date: Tue, 22 Feb 2022 11:43:57 +0800 Subject: [PATCH] updated README for docker --- admin/README.md | 33 ++++++++++++++++++++++----------- myems-api/README.md | 26 ++++++++++++-------------- web/README.md | 32 +++++++++++++++++++++++++------- 3 files changed, 59 insertions(+), 32 deletions(-) diff --git a/admin/README.md b/admin/README.md index 0635bb81..dd3d1f41 100644 --- a/admin/README.md +++ b/admin/README.md @@ -25,30 +25,41 @@ nano nginx.conf ``` * Build a Docker image + +On Windows: ```bash -cd myems/admin +cp -r myems/admin c:\myems-admin +cd c:\myems-admin docker build -t myems/myems-admin . ``` + +On Linux: +```bash +cp -r myems/admin /myems-admin +cd /myems-admin +docker build -t myems/myems-admin . +``` + * Run a Docker container -If run on Windows host, bind-mount a share upload file folder at c:\myems-upload to the container --v parameter must be same with that in myems-api +If run on Windows host, bind-mount a share upload file folder at c:\myems-upload to the container and also bind-mount nginx.conf +-v parameter for upload folder must be same with that in myems-api ```bash -docker run -d -p 8001:8001 -v c:\myems-upload:/var/www/html/admin/upload --restart always --name myems-admin myems/myems-admin +docker run -d -p 8001:8001 -v c:\myems-upload:/var/www/html/admin/upload -v c:\myems-admin/nginx.conf:/etc/nginx/nginx.conf --restart always --name myems-admin myems/myems-admin ``` -If run on Linux host, bind-mount a share upload file folder at /myems-upload to the container +If run on Linux host, bind-mount a share upload file folder at /myems-upload to the container and also bind-mount nginx.conf ```bash -docker run -d -p 8001:8001 -v /myems-upload:/var/www/html/admin/upload --restart always --name myems-admin myems/myems-admin +docker run -d -p 8001:8001 -v /myems-upload:/var/www/html/admin/upload -v /myems-admin/nginx.conf:/etc/nginx/nginx.conf --restart always --name myems-admin myems/myems-admin ``` --d Run container in background and print container ID +-d Run container in background and print container ID --p Publish a container's port(s) to the host, 8001:8001 (Host:Container) binds port 8001 (right) of the container to TCP port 8001 (left) of the host machine. +-p Publish a container's port(s) to the host, 8001:8001 (Host:Container) binds port 8001 (right) of the container to TCP port 8001 (left) of the host machine. --v If you use -v or --volume to bind-mount a file or directory that does not yet exist on the Docker host, -v creates the endpoint for you. It is always created as a directory. +-v If you use -v or --volume to bind-mount a file or directory that does not yet exist on the Docker host, -v creates the endpoint for you. It is always created as a directory. ---restart Restart policy to apply when a container exits +--restart Restart policy to apply when a container exits ---name Assign a name to the container +--name Assign a name to the container If you want to immigrate the image to another computer, * Export image to tarball file diff --git a/myems-api/README.md b/myems-api/README.md index 59a028e7..c3f23a4f 100644 --- a/myems-api/README.md +++ b/myems-api/README.md @@ -45,20 +45,6 @@ chmod +x run.sh In this section, you will install myems-api on Docker. -* Copy source code to root directory - -On Windows: -```bash -cp -r myems/myems-api c:\ -cd c:\myems-api -``` - -On Linux: -```bash -cp -r myems/myems-api / -cd /myems-api -``` - * Duplicate example.env file as .env file and modify the .env file Replace ~~127.0.0.1~~ with real **HOST** IP address. ```bash @@ -66,9 +52,21 @@ cp example.env .env ``` * Build a Docker image + +On Windows: ```bash +cp -r myems/myems-api c:\ +cd c:\myems-api docker build -t myems/myems-api . ``` + +On Linux: +```bash +cp -r myems/myems-api / +cd /myems-api +docker build -t myems/myems-api . +``` + * Run a Docker container On Windows host, bind-mount a share upload folder at c:\myems-upload to the container, and also bind-mount the .env to the container: diff --git a/web/README.md b/web/README.md index 1e0bf7b0..2c46c3c3 100644 --- a/web/README.md +++ b/web/README.md @@ -73,27 +73,45 @@ nano nginx.conf ```bash npm i --unsafe-perm=true --allow-root --legacy-peer-deps ``` + * Build for production with NPM ```bash npm run build ``` + * Build a Docker image + +On Windows: ```bash -cd myems/web +cp -r myems/web c:\myems-web +cd c:\myems-web docker build -t myems/myems-web . ``` -* Run a Docker container + +On Linux: ```bash -docker run -dp 80:80 --restart always --name myems-web myems/myems-web +cp -r myems/web /myems-web +cd /myems-web +docker build -t myems/myems-web . ``` --d Run container in background and print container ID +* Run a Docker container +If run on Windows host, bind-mount nginx.conf to the container +```bash +docker run -d -p 80:80 -v c:\myems-web/nginx.conf:/etc/nginx/nginx.conf --restart always --name myems-web myems/myems-web +``` +If run on Linux host, bind-mount nginx.conf +```bash +docker run -d -p 80:80 -v /myems-web/nginx.conf:/etc/nginx/nginx.conf --restart always --name myems-web myems/myems-web +``` --p Publish a container's port(s) to the host, 8001:8001 (Host:Container) binds port 8001 (right) of the container to TCP port 8001 (left) of the host machine. +-d Run container in background and print container ID ---restart Restart policy to apply when a container exits +-p Publish a container's port(s) to the host, 80:80 (Host:Container) binds port 80 (right) of the container to TCP port 80 (left) of the host machine. ---name Assign a name to the container +--restart Restart policy to apply when a container exits + +--name Assign a name to the container If you want to immigrate the image to another computer, * Export image to tarball file