当我尝试使用远程api创建django docker容器时,我可以将主机卷绑定到docker容器卷。但是当我使用" Cmd"与docker一起创建,它显示错误(不适用于shell命令),
<Response [500]>
Cannot start container d07b316a1d790b67442a9a4ee49de6e6f2191e14d15ebd528d752b3fad63d9b1: exec: "pip install -r requirements.txt&& python manage.py runserver 0.0.0.0:8888": executable file not found in $PATH
这是我的json输入。
d = {
"Hostname": "",
"Domainname": "",
"User": "",
"Memory": 0,
"MemorySwap": 0,
"CpuShares": 512,
"Cpuset": "0,1",
"AttachStdin": True,
"AttachStdout": True,
"AttachStderr": True,
"Tty": True,
"OpenStdin": True,
"StdinOnce": False,
"Env": "[$PATH=/usr/local/bin]",
"Cmd": [
"pip install -r requirements.txt&& python manage.py runserver 0.0.0.0:8888"
],
"Entrypoint": "",
"Image": "django:python3",
"Volumes": {
"/usr/src/app": {},
},
"WorkingDir": "/usr/src/app",
"NetworkDisabled": False,
"MacAddress": mac_id,
"ExposedPorts": {
"8888/tcp": {}
},
"SecurityOpts": [""],
"HostConfig": {
"Binds": ["/home/user/Sample:usr/src/app"],
"Links": [],
"LxcConf": {"lxc.utsname":"docker"},
"PortBindings": { "8888/tcp": [{ "HostPort": "8888" }] },
"PublishAllPorts": False,
"Privileged": False,
"ReadonlyRootfs": False,
"Dns": ["8.8.8.8"],
"DnsSearch": [""],
"ExtraHosts": '',
"VolumesFrom": [],
"CapAdd": ["NET_ADMIN"],
"CapDrop": ["MKNOD"],
"RestartPolicy": { "Name": "", "MaximumRetryCount": 0 },
"NetworkMode": "bridge",
"Devices": []
}
}
使用&#34; docker run&#34;命令它适合我。我该如何解决这个问题。
答案 0 :(得分:0)
您确定在容器内安装了pip
吗?例如,在Debian衍生系统上你的Dockerfile应该有:
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get -y install python-pip
答案 1 :(得分:0)
我还没有使用过远程API,但问题是您已将所有内容作为单个参数传递,因此它正在寻找名为"pip install -r requirements.txt&& python manage.py runserver 0.0.0.0:8888"
的文件。
您需要弄清楚如何单独传递参数,并且您可能需要提供pip的绝对路径。