我试图将我的源文件挂载到位于/var/dynamo的docker目录中。我希望能够在本地运行Docker,并在工作时使用我的本地文件。
使用run命令:
docker run -v $(pwd):/var/dynamo -d -t -p 8001:8001 --name dynamo davesrepo/dynamo
FROM python:3.5.1
WORKDIR /var/dynamo
RUN pip3 install tornado
EXPOSE 8001
root@7d3d338891aa:/var/dynamo# ls -la
total 4
drwxr-xr-x 2 root root 40 Dec 29 03:37 .
drwxr-xr-x 24 root root 4096 Dec 29 03:36 ..
[
{
"Id": "7d3d338891aae32e001a3bb31d6be17802d238526830396472b011599a97212a",
"Created": "2015-12-29T03:37:01.416445958Z",
"Path": "python3",
"Args": [],
"State": {
"Status": "running",
"Running": true,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 1314,
"ExitCode": 0,
"Error": "",
"StartedAt": "2015-12-29T03:37:01.516253705Z",
"FinishedAt": "0001-01-01T00:00:00Z"
},
"Image": "19697c9b5c7561b113d817821280971f063ea0187c82343c0832348fb6863c9a",
"ResolvConfPath": "/mnt/sda1/var/lib/docker/containers/7d3d338891aae32e001a3bb31d6be17802d238526830396472b011599a97212a/resolv.conf",
"HostnamePath": "/mnt/sda1/var/lib/docker/containers/7d3d338891aae32e001a3bb31d6be17802d238526830396472b011599a97212a/hostname",
"HostsPath": "/mnt/sda1/var/lib/docker/containers/7d3d338891aae32e001a3bb31d6be17802d238526830396472b011599a97212a/hosts",
"LogPath": "/mnt/sda1/var/lib/docker/containers/7d3d338891aae32e001a3bb31d6be17802d238526830396472b011599a97212a/7d3d338891aae32e001a3bb31d6be17802d238526830396472b011599a97212a-json.log",
"Name": "/dynamo",
"RestartCount": 0,
"Driver": "aufs",
"ExecDriver": "native-0.2",
"MountLabel": "",
"ProcessLabel": "",
"AppArmorProfile": "",
"ExecIDs": null,
"HostConfig": {
"Binds": [
"/Users/dave/Sites/davesrepo/dynamo:/var/dynamo"
],
"ContainerIDFile": "",
"LxcConf": [],
"Memory": 0,
"MemoryReservation": 0,
"MemorySwap": 0,
"KernelMemory": 0,
"CpuShares": 0,
"CpuPeriod": 0,
"CpusetCpus": "",
"CpusetMems": "",
"CpuQuota": 0,
"BlkioWeight": 0,
"OomKillDisable": false,
"MemorySwappiness": -1,
"Privileged": false,
"PortBindings": {
"8001/tcp": [
{
"HostIp": "",
"HostPort": "8001"
}
]
},
"Links": null,
"PublishAllPorts": false,
"Dns": [],
"DnsOptions": [],
"DnsSearch": [],
"ExtraHosts": null,
"VolumesFrom": null,
"Devices": [],
"NetworkMode": "default",
"IpcMode": "",
"PidMode": "",
"UTSMode": "",
"CapAdd": null,
"CapDrop": null,
"GroupAdd": null,
"RestartPolicy": {
"Name": "no",
"MaximumRetryCount": 0
},
"SecurityOpt": null,
"ReadonlyRootfs": false,
"Ulimits": null,
"LogConfig": {
"Type": "json-file",
"Config": {}
},
"CgroupParent": "",
"ConsoleSize": [
0,
0
],
"VolumeDriver": ""
},
"GraphDriver": {
"Name": "aufs",
"Data": null
},
"Mounts": [
{
"Source": "/Users/dave/Sites/davesrepo/dynamo",
"Destination": "/var/dynamo",
"Mode": "",
"RW": true
}
],
"Config": {
"Hostname": "7d3d338891aa",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"ExposedPorts": {
"8001/tcp": {}
},
"Tty": true,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"APP_ENV=development",
"PYTHONPATH=$PYTHONPATH:/var/dynamo",
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"LANG=C.UTF-8",
"PYTHON_VERSION=3.5.1",
"PYTHON_PIP_VERSION=7.1.2"
],
"Cmd": [
"python3"
],
"Image": "davesrepo/dynamo",
"Volumes": null,
"WorkingDir": "/var/dynamo",
"Entrypoint": null,
"OnBuild": null,
"Labels": {},
"StopSignal": "SIGTERM"
},
"NetworkSettings": {
"Bridge": "",
"SandboxID": "71d99a7d11908a9d1c0156fd33eb3f0ff5ef9f6697bb77103fe2caa1cf488530",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": {
"8001/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "8001"
}
]
},
"SandboxKey": "/var/run/docker/netns/71d99a7d1190",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "1cc99b0de89700368f31b43248c90ea45cec756712a2bd2ba2dc57293a5d0a72",
"Gateway": "172.17.0.1",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"IPAddress": "172.17.0.2",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"MacAddress": "02:42:ac:11:00:02",
"Networks": {
"bridge": {
"EndpointID": "1cc99b0de89700368f31b43248c90ea45cec756712a2bd2ba2dc57293a5d0a72",
"Gateway": "172.17.0.1",
"IPAddress": "172.17.0.2",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "02:42:ac:11:00:02"
}
}
}
}
]
Docker版本为1.9.1
Docker和Virtualbox似乎在安装/users目录之外的卷时存在问题。解决该问题的唯一方法是删除docker机器映像,正确地将/users/yourname目录设置为Virtualbox中的共享文件夹,并创建一个新的docker机器映像。
解决此问题的步骤:
docker-机器停止dev
docker-machine rm dev
docker-机器创建--driver virtualbox dev
eval“$(docker-machine env dev)”
docker build-t davesrepo/dynamo-f./dockerfile.
docker run-v$(pwd)://var/dynamo-d-t-p 8001:8001--env-file./dynamo.env--name dynamo davesrepo/dynamo
Docker exec-it dynamo/bin/bash
ls
文件!
问题内容: 我正在尝试将源文件安装到位于/ var / dynamo的Docker目录中。我希望能够在本地运行Docker并在工作时使用本地文件。 使用运行命令: 与我的 Dockerfile 但是,当我将bash放入容器并运行时,该目录 为空! 运行显示目录已正确安装 Docker版本是1.9.1 问题答案: Docker&Virtualbox在将卷装载到/ Users目录之外时似乎出现了问题。
问题内容: 我在Windows中使用Docker Toolbox,并尝试将Windows文件夹安装在docker-compose.yml文件中,如下所示: 我的目标是将Docker Toolbox已经创建的boot2docker VM映像安装到该映像,然后从该映像加载到其中的nginx容器。 不幸的是,它不起作用。我在boot2docker映像中找到一个文件夹sss,但是它没有指定我的Window
问题内容: 我最近创建了一个在Windows上的boot2docker上运行的mongodb docker实例。 不幸的是,在尝试kitematic的过程中,我意外地从mongo容器中删除了该卷,并且无法再访问我的数据。 mongo实例似乎创建了一个新卷,而旧卷现在仍悬空(孤立)并且未安装在任何容器中。 有什么办法可以恢复吗? 问题答案: 感谢您的答复,它使我处于正确的轨道,我设法使用以下命令启动
问题内容: 我有一个.net Core Web Api,其配置文件位于名为Config的文件夹下。我从中创建了图像和一个容器,并且使用终端可以正确看到该容器中包含文件夹和配置文件。 我的问题是,到目前为止,按照要求,我找不到找到将相同的容器安装/绑定Config文件夹绑定到物理路径的容器的方法: 1)将Config文件夹挂载到特定的主机位置 2)在创建容器时,Config文件夹应填充映像中的文件
问题内容: 我正在运行一个Jenkins集群,其中在Master和Slave中,它们都作为Docker容器运行。 主机是在MacOS上运行的最新的boot2docker VM。 为了使Jenkins能够使用Docker执行部署,我将docker.sock和docker客户端从主机安装到Jenkins容器,如下所示: 在将卷装载到Jenkins容器中运行的Docker容器时,我遇到了问题。例如,如果
我有一个在容器中运行的web应用程序。该应用程序允许用户上传文件。这些文件存储在Docker卷和中。 做这件事的适当方法是什么? Docker-compose.yml