Docker小记

来源:互联网 发布:超少年密码之人工智能 编辑:程序博客网 时间:2024/04/28 18:44

Docker小记

  由于ubuntu16.04还不支持paddle paddle,所以就用了下docker。官网上安装都很详细了,这里记录一些比较蛋疼的方法。如果你想要在运行的docker容器里面访问ubuntu本地的文件咋办?你发现运行一个容器进入了一个新linux环境,无法看到你的ubuntu主机文件了,更不用说访问和运行了。此时就需要知道docker和宿主机之间的数据共享了!

docker share data between a docker container and host system using volumes

mkdir data1echo "docker data share with host system" >> data1/filedocker run -v $PWD/data1:/opt/data1 -it paddledev/paddle:cpu-latest /bin/bashcat /opt/data1/fileError 1:FATA[0000] Error response from daemon: cannot bind mount volume: data1 volume paths must be absolute.You need to supply a full path to both source and destination directories. Hint: the full path always starts with /. Error 2:# ls /opt/data1/ ls: cannot open directory /opt/data1/: Permission deniedThis error is caused by SElinux running on your local host system. The following two solutions will help to solve this issue. First, solution is to disable SElinux on your local host system.# setenforce 0Since disabling the SElinux may hinder an integrity of your host system it may be easier to give an extended privileges to your container instead, with a docker --privileged=true option:# docker run --privileged=true -v $PWD/data1:/opt/data1 -it paddledev/paddle:cpu-latest /bin/bash
0 0