Experimenting with Docker for the first time. Have these steps in my Dockerfile to create a directory, but when I run the container, the directory isn't there.
FROM ubuntu
MAINTAINER AfterWorkGuinness
RUN apt-get update
RUN apt-get install -y openssh-server
RUN mkdir /root/.ssh
RUN cd /root/.ssh
RUN ssh-keygen -t rsa -N "" -f id_rsa
VOLUME /root
EXPOSE 22
Run Code Online (Sandbox Code Playgroud)
Build image:
docker build -t ubuntu-ssh --no-cache .
Run Code Online (Sandbox Code Playgroud)
Testing the directory when I run the container:
docker run -it -v c:/users/awg/dev/tmp/home:/root ubuntu-ssh
root@39eec8fa51ad:/# cd ~/.ssh
bash: cd: /root/.ssh: No such file or directory
root@39eec8fa51ad:/# cd /root/.ssh
bash: cd: /root/.ssh: No such file or directory
Run Code Online (Sandbox Code Playgroud)
docker run -v tmphome:/root whatever
Run Code Online (Sandbox Code Playgroud)
在命名卷中,文件在容器重新启动时仍将保留,但目录中的内容将在创建时复制到已安装的卷中。Docker 根据使用的驱动程序选择存储数据的位置。local是默认值,数据默认为volumeDocker 数据目录中的目录,通常/var/lib/docker/volumes
| 归档时间: |
|
| 查看次数: |
3358 次 |
| 最近记录: |