[Docker2] Dockerfile, deployment


1.Dockerfile

Insert picture description here
Image image program, container image process FROM: Specify which image the current image is based on, required.

WORKDIR: Specify the path under which the next shell statement will run. There must be no /app directory under the alpine mirror, and it will be created automatically.

COPY: Copy the current 宿主机文件to the mirror. ADDSimilar to COPY, both can be copied from the outside to the mirror. Generally, the source address of COPY is the source address of the file system. The source address of ADD is not only the file system but also a URL. If network resources are not used, just use COPY.

RUN: Run this script when building the container, and the current working directory is /app.

CMD: Specify the entire container to start up and run the script, and the entire container life cycle will end after running (tail -f blocking).

ENTRYPOINT: Specify the core script that the container starts up like CMD, but specify both ENTRYPOINT and CMD, whichever prevails: ENTRYPOINT非jsonENTRYPOINT shall prevail, CMD is invalid, if ENTRYPOINT and CMD are both json, ENTRYPOINT+CMD forms a shell. The following can be specified in the form of a json array.
Insert picture description here
It must be named Dockerfile.
Insert picture description here
Specify the mirror name test as follows. The last dot indicates that the dockfile file is located in the current directory
Insert picture description here
. The original content in 1.txt contains 123
Insert picture description here
EXPOSE: Specify a port exposed by the current mirror. For example, the nginx mirror specifies EXPOSE to expose port 80, exposing benefits. It uses docker run -P to map port 80 to a random port of the machine. In docker run --network=host mode, port 80 will be directly bound to port 80 of the machine.
Insert picture description here
Insert picture description here
VOLUME: Specify the mapping file, VOLUME /a/b maps the directory /a/b in the container to a directory on the host machine.

1.1 ENV

Specifying parameters: The first is to ENVdirectly specify the environment variables of the current container. The environment variables can be specified in docker run -e, or directly specified in ENV in the Dockerfile. A=10 and A space 10 are the same.

The second one is ARG(it means a parameter). ENV and ARG have an essential difference: ENV is an environment variable that takes effect from build time to run time. It is an environment variable of the system. ARG is a build parameter. (Docker build) is valid only when it is running, it is invalid when it is actually running.
Insert picture description here
Insert picture description here
The following b=11 defaults to 11, which is specified during construction
Insert picture description here
Insert picture description here

1.2 LABEL

LABEL: It has no effect on the image, it is just an identification, it is easy to find the image through the docker inspect command
Insert picture description here
ONBUILD: the parameter can be any other parameter
Insert picture description here
ONBUILDin the Dockerfile, which will not be executed when the current image is built, but will be executed during the 基于当前镜像的镜像build
Insert picture description here
Insert picture description here
Insert picture description here

2.Docker deployment

2.1 Deployment

Insert picture description here
1.Copy the server/as folder to the deployment server.
2.Log in to the Docker Hub server, enter the username/password: sudo docker login huangpu.azurecr.io
3.Download Docker to the deployment server, enter the as folder, run: sudo sh pullAzure_mkroo.sh
4.enter the as folder, check and modify each sub-file Folder the settings in the rundocker.sh file
Insert picture description here
5.into the as folder, check and modify the settings in each .service file
Insert picture description here

2.2 Configuration

Insert picture description here

2.3 Operation

Insert picture description here
Insert picture description here
Insert picture description here

2.4 Inspection

Before the following verification, ensure that the server is connected to the Internet and the camera is powered on:
1.验证docker是否开机启动?
sudo docker ps, if there are 5 Up in the figure below, it means that 5 dockers are started normally.
Insert picture description here
2.查看各个docker的工作log
Take accessserver as an example: sudo docker logs accessserver
3.查看accessserver的log也可以如下途径查看
方法一:
sudo docker exec –it accessserver /bin /bash Enter accessserver
cd log
ls
cat [latest log name]
tail -f [latest log name] cd /accessserver/log/ ls cat [latest log name] in the
方法二:
Home directory tail -f [latest log name] sudo docker exec –it accessmysql /bin/bash mysql –uroot –ppassword; use access_data; select * from camera; View camera data table information, you can see all camera information select * from shelf; View shelf data table information, you can view Binding relationship to all shelves and cameras update shelf set camera_id=? where id=?; Modify shelf-bound camera update camera set binding_status=0 where id=?; Unbind the old camera (broken camera), That is, the binding status is set to 0




4.进入数据库方法







update camera set binding_status=1 where id=?; Set the new camera binding status to 1

Guess you like

Origin blog.csdn.net/weixin_43435675/article/details/112427736