1
0
mirror of https://github.com/phusion/baseimage-docker.git synced 2026-03-26 04:18:46 +00:00

Use COPY instead of ADD

While COPY and ADD are essentially interchangeable here, it is still
considered good practice to use COPY whenever possible. From the docker
docks on best practices:

"Although ADD and COPY are functionally similar, generally speaking,
COPY is preferred. That’s because it’s more transparent than ADD.
[...] For other items (files, directories) that do not require ADD’s tar
auto-extraction capability, you should always use COPY."

Additionally, ADD commands were not cached prior to 0.7.3 (which was
released on 2013-01-02).
This commit is contained in:
Alexander Buddenbrock
2015-03-17 20:35:16 +01:00
parent 6052c7a3e7
commit 17eadef537
4 changed files with 10 additions and 10 deletions

View File

@@ -156,7 +156,7 @@ The image is called `phusion/baseimage`, and is available on the Docker registry
### 在Dockerfile中:
RUN mkdir /etc/service/memcached
ADD memcached.sh /etc/service/memcached/run
COPY memcached.sh /etc/service/memcached/run
注意脚本必须运行在后台的,**不能让他们进程进行daemonize/fork**.通常,后台进程会提供一个标志位或者配置文件.
@@ -178,7 +178,7 @@ baseimage-docker的初始化脚本 `/sbin/my_init`,在启动的时候进程运
### 在 Dockerfile中:
RUN mkdir -p /etc/my_init.d
ADD logtime.sh /etc/my_init.d/logtime.sh
COPY logtime.sh /etc/my_init.d/logtime.sh
<a name="environment_variables"></a>
@@ -487,7 +487,7 @@ Baseimage-docker提供了一个灵活的方式运行只要一闪而过的命令,
编辑你的dockerfile,来安装ssh public key:
## 安装你自己的public key.
ADD your_key.pub /tmp/your_key.pub
COPY your_key.pub /tmp/your_key.pub
RUN cat /tmp/your_key.pub >> /root/.ssh/authorized_keys && rm -f /tmp/your_key.pub
重新创建你的镜像.一旦你创建成功,启动基于这个镜像的容器.