繁体   English   中英

Docker从主机安装到远程

[英]Docker mount from host to remote

我运行了一个在docker run -d -p 80:80 p0bailey/docker-flask上在Docker上运行的Flask样板应用程序,并且工作正常( 192.168.99.100显示了一个页面)。 接下来,我从github克隆了相同的应用程序,并尝试使用以下命令从主机目录挂载到容器中

docker run -d -p 80:80 -v /Users/username/docker-flask/app:/var/www/app p0bailey/docker-flask

我去了URL 92.168.99.100并得到502 Bad Gateway

我究竟做错了什么?

主机是一分OS 7

$ docker ps -a
CONTAINER ID        IMAGE                   COMMAND                  CREATED             STATUS              PORTS                NAMES
721e7cfac4de        p0bailey/docker-flask   "/usr/bin/supervisord"   10 seconds ago      Up 8 seconds        0.0.0.0:80->80/tcp   stoic_newton

这是日志

$ docker logs 721e7cfac4de
/usr/lib/python2.7/dist-packages/supervisor/options.py:295: UserWarning: Supervisord is running as root and it is searching for its configuration file in default locations (including its current working directory); you probably want to specify a "-c" argument specifying an absolute path to a configuration file for improved security.
  'Supervisord is running as root and it is searching '
2016-07-28 21:14:32,788 CRIT Supervisor running as root (no user in config file)
2016-07-28 21:14:32,788 WARN Included extra file "/etc/supervisor/conf.d/supervisord.conf" during parsing
2016-07-28 21:14:32,808 INFO RPC interface 'supervisor' initialized
2016-07-28 21:14:32,808 CRIT Server 'unix_http_server' running without any HTTP authentication checking
2016-07-28 21:14:32,808 INFO supervisord started with pid 1
2016-07-28 21:14:33,812 INFO spawned: 'nginx' with pid 10
2016-07-28 21:14:33,813 INFO spawned: 'uwsgi' with pid 11
2016-07-28 21:14:33,869 INFO exited: uwsgi (exit status 1; not expected)
2016-07-28 21:14:34,908 INFO success: nginx entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2016-07-28 21:14:34,909 INFO spawned: 'uwsgi' with pid 16
2016-07-28 21:14:34,915 INFO exited: uwsgi (exit status 1; not expected)
2016-07-28 21:14:36,920 INFO spawned: 'uwsgi' with pid 17
2016-07-28 21:14:36,926 INFO exited: uwsgi (exit status 1; not expected)
2016-07-28 21:14:39,934 INFO spawned: 'uwsgi' with pid 18
2016-07-28 21:14:39,942 INFO exited: uwsgi (exit status 1; not expected)
2016-07-28 21:14:40,943 INFO gave up: uwsgi entered FATAL state, too many start retries too quickly

-v /Users/username/docker-flask/app:/var/www/app/Users/username/docker-flask/app的内容覆盖容器的内容

如果要挂载/var/www/app而不丢失原始容器文件,请使用

docker run -d -p 80:80 -v /var/www/app p0bailey/docker-flask

然后使用以下命令在主机文件系统中找到卷的随机位置

docker inspect -f "{{json .Mounts}}" development-phase \
 | jq '.[] | select(.Destination | contains("/var/www/app"))'

发现这与/ app的读写权限有关。 将SELinux切换到许可模式已解决的问题。

vim /etc/selinux/config

#look for line SELINUX and set to permissive
SELINUX=permissive

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM