1. UseDocke
R to the frontvue
Project Deployment
1.1 Environment Preparations
Install the server or VM firstNginx
And related configurations
docker pull nginx
Pull the latest versionnginx
- run
nginx
.docker run --name=mynginx -d -p 8080:80 nginx
- Then develop port 80 in the server security group or firewall and type in the browser
ip:8080
If this screen logo appearsnginx
Successful installation
1.2 Vue project preparation
- Package the VUE project by specifying
npm run build
Package the project to generate the DIST folder - Create files in the root directory of your project
Dockerfile
There is no file suffix. The file configuration is as follows
Step 1 has installed the latest version of nginx
FROM nginx
# define author name
MAINTAINER xiongchao
Copy the dist folder to /usr/share/nginx/html/
COPY dist/ /usr/share/nginx/html/
Copy the code
- Upload the files, create a folder on the server in a location you specify (easy to deploy yourself), and upload the dist folder and Dockerfile files to a directory
- Build the mirror
docker build -t myvueproject .
- through
docker images
To check whether the mirror is successfully constructed - Boot image
docker run --name=dockervue -d -p 8001:8080 myvueproject
- through
ip:8001
To see the successful deployment of the project
2. UseDockerfile
forspringboot
Application of buildingdocker
The mirror
2.1 Docker
Common instructions
ADD
Used to copy files
ADD < SRC > <dest> # ADD test.jar /test.jar to docker container/directoryCopy the code
ENTRYPOINT
Specifies the command to start docker
ENTRYPOINT [" Java ","-jar","/test.jar"]Copy the code
ENV
Used to set environment variables in the following format
ENV MYSQL_ROOT_PASSWORD rootCopy the code
EXPOSE
Declare exposed ports
EXPOSE <port> <port2> # example EXPOSE 8080Copy the code
FROM
Specify the base image that you want to rely on
FROM <image>:<tag> #Copy the code
MAINTAINER
Specify the name of the maintainer
MAINTAINER <name> # Example MAINTAINER XiongcCopy the code
RUN
Commands executed during container construction, such as installing other related dependencies or as required by the environment
RUN <command> # example RUN bash -c 'touch /test.jar'Copy the code
2.2 Detailed Configuration file and Description
FROM java:8
ADD test.jar /test.jar
RUN bash -c 'touch /test.jar'
EXPOSE 8080
ENTRYPOINT ['java'.'-jar'.'/test.jar']
MAINTAINER xiongchao
Copy the code
2.3 Starting Construction
- Will be packaged
jar
anddockerfile
Upload to the specified path of the server - Build the mirror
Docker build -t javaproject/javaprojectCopy the code
- Start the project
docker run --name=tomcatA01 -d -p 8002:8080 javaproject
Copy the code