Usually, we first define the Dockerfile file, and then build the image file through the docker build command. Then, you can start a container instance based on the image file through docker run. Then when starting a container, you can change some parameters in the image file, and these parameters in the image file are often defined by the Dockerfile file. But not all definitions in the Dockerfile file can be redefined when starting the container. The Dockerfile instructions that cannot be overwritten by docker run are as follows:
1. Overwrite the ENTRYPOINT instruction The ENTRYPOINT instruction in the Dockerfile file is used to give the default entry point after the container is started.
2. Overwrite CMD command The CMD instruction in the Dockerfile file gives the default instructions to be executed after the container is started. When starting the container, you can set new command options for docker run to overwrite the CMD instruction in the Dockerfile file (the CMD instruction in the Dockerfile file will no longer be consulted). Here is an example:
If the ENTRYPOINT instruction is also declared in the Dockerfile file, the above instructions will be appended to the ENTRYPOINT instruction as parameters. 3. Override the EXPOSE instruction The EXPOSE instruction in the Dockerfile file is used to reserve ports for the host where the container is located. Apparently this is a feature of the runtime container, so docker run can conveniently override that instruction. Here is an example:
4. Override ENV directive The ENV instruction in the Dockerfile file is used to set the environment variables in the container. When starting a container, the following environment variables are automatically set for the container:
docker run can conveniently override this instruction. Here is an example: declare -x HOME="/" declare -x HOSTNAME="85bc26a0e200" declare -x OLDPWD declare -x PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" declare -x PWD="/" declare -x SHLVL="1" declare -x deep="purple" Setting or overriding environment variables via scripts 5. Override the VOLUME instruction The VOLUME instruction in the Dockerfile is used to set data volumes for the container.
6. Overwrite USER command The default user inside the container is root (uid=0).
Docker run supports the following forms of -u:
7. Override the WORKDIR directive The WORKDIR instruction in the Dockerfile file is used to set the working directory for subsequent instructions. If the path does not exist, it is created even if it is not used in subsequent instructions. In one, multiple WORKDIRs can exist. For relative paths, subsequent instructions inherit from the previous instruction. In WORKDIR, you can reference previously defined environment variables.
Reference Links: https://docs.docker.com/engine/reference/run/ https://docs.docker.com/engine/reference/builder/ Summarize The above is the full content of this article. I hope that the content of this article will have certain reference learning value for your study or work. Thank you for your support of 123WORDPRESS.COM. If you want to learn more about this, please check out the following links You may also be interested in:
|
<<: Implementing countdown effect with javascript
>>: JavaScript to achieve drop-down menu effect
There are two types: (different browsers) 1. Avail...
Why do I want to organize the content in this area...
MySQL executes SQL through the process of SQL par...
Table of contents 1. Follow the wizard to create ...
Table of contents 1. Content Overview 2. Concepts...
Three functions: 1. Automatic vertical centering o...
Use CSS to create a 3D photo wall. The specific c...
1. Download MySQL Workbench Workbench is a graphi...
What is wxs? wxs (WeiXin Script) is a scripting l...
Installation Environment 1. gcc installation To i...
The requirement is to pass in the rating data for...
Preface Tip: The following is the main content of...
After the container is started Log in to admin fi...
background As the company's sub-projects incr...
1. Alipay method: Alipay method: Click Alipay to ...