Construction of two ways mirror docker-

From the construction of container - container after repeated changes, but do not know the specific modification history; not familiar with the command dockerfile

$ docker ps

CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS              NAMES
c3f279d17e0a        ubuntu:12.04        /bin/bash           7 days ago          Up 25 hours                            desperate_dubinsky
197387f1b436        ubuntu:12.04        /bin/bash           7 days ago          Up 25 hours                            focused_hamilton

$ docker commit --change='CMD ["apachectl", "-DFOREGROUND"]' -c "EXPOSE 80" c3f279d17e0a  svendowideit/testimage:version4

f5283438590d

$ docker run -d svendowideit/testimage:version4

89373736e2e7f00bc149bd783073ac43d0507da250e999f3f1036e0db60817c0

$ docker ps

CONTAINER ID        IMAGE               COMMAND                 CREATED             STATUS              PORTS              NAMES
89373736e2e7        testimage:version4  "apachectl -DFOREGROU"  3 seconds ago       Up 2 seconds        80/tcp             distracted_fermat
c3f279d17e0a        ubuntu:12.04        /bin/bash               7 days ago          Up 25 hours                            desperate_dubinsky
197387f1b436        ubuntu:12.04        /bin/bash               7 days ago          Up 25 hours           

Built from dockerfile - a step of building a mirror; familiar dockerfile instruction

docker build dockerfile

Reference dockerfile official documentation
FROM
the start dockerfile, specifying the base on which to build a mirror image.
LABEL
specified meta data image (key-value pairs) (such as specifying OF: maintainer = xxl).
ENV
specifying environment variables, recommend key way (key = value) of.
WORKDIR
designated RUN, CMD, ENTRYPOINT, COPY and ADD working directory, you can set more than once, each time set to take effect later.
The ADD - may be a remote file
to copy the new files from the source address, remote file or directory url, and add them to the target path of the mirror.
COPY - can not be a remote file
to copy new files or directories from the source directory, and add them to the target path of the container.
EXPOSE
designated port to listen containers running, you can specify the protocol udp / tcp, not specified, the default is tcp.

EXPOSE 80/udp

VOLUME
mount point of the container and put it as a host or other external container to mount the volume.
RUN
execution of commands, such as create folders, open configuration, etc., can have multiple, each effect.
CMD
specify the default execution command, you can have more, but only the last one will work, docker run the command line can be specified command reload.
EntryPoint
The mirror can be configured to run the executable file like,
the USER
specified image or performing runtime user name and user groups a time RUN, CMD, ENTRYPOINT command.

Published 21 original articles · won praise 0 · Views 827

Guess you like

Origin blog.csdn.net/ssehs/article/details/103850928