配置y总docker
Posted 卷王2048
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了配置y总docker相关的知识,希望对你有一定的参考价值。
配置y总docker
问题
1.新容器在运行
uwsgi --ini scripts/uwsgi.ini
时可以成功,但源网址(https://app220.acapp.acwing.com.cn/
)无法访问
log信息
*** Starting uWSGI 2.0.20 (64bit) on [Thu Dec 30 07:23:11 2021] *** [25/56]
compiled with version: 9.3.0 on 28 October 2021 05:02:51
os: Linux-5.4.0-86-generic #97-Ubuntu SMP Fri Sep 17 19:19:40 UTC 2021
nodename: 2708dab4e09c
machine: x86_64
clock source: unix
detected number of CPU cores: 1 current working directory: /home/doctao/acapp
detected binary path: /usr/local/bin/uwsgi !!! no internal routing support, rebuild with pcre support !!!
chdir() to /home/doctao/acapp your memory page size is 4096 bytes
detected max file descriptor number: 1024 lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to TCP address 127.0.0.1:8000 fd 3
Python version: 3.8.10 (default, Sep 28 2021, 16:10:42) [GCC 9.3.0]
Python main interpreter initialized at 0x56304561aa90
python threads support enabled
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 344232 bytes (336 KB) for 10 cores
*** Operational MODE: preforking+threaded ***
WSGI app 0 (mountpoint='') ready in 0 seconds on interpreter 0x56304561aa90 pid: 63 (default app)
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 63)
spawned uWSGI worker 1 (pid: 65, cores: 5)
spawned uWSGI worker 2 (pid: 66, cores: 5)
^CSIGINT/SIGTERM received...killing workers..
尝试运行
python3 manage.py 0.0.0.0:8000
请求到了静态资源却只能加载背景图片
docker不删除容器改端口号的方法
-
停止docker服务
systemctl stop docker
-
编辑
/var/lib/docker/containers/容器id/hostconfig.json
,在里面就能修改端口映射 -
启动docker服务
systemctl start docker
-
启动docker容器
docker start `docker ps -aq`
发现原因
折腾了一上午,终于发现了原因
结论
容器的8000和22端口可以随意映射,80和443端口只能映射到你服务器的80和443端口
最终的docker-compose.yml
version: '3.8'
services:
acgame:
container_name: acgame
image: django_lesson:2.0
working_dir: /home/doctao/acapp
tty: true
ports:
- "20000:22"
- "8000:8000"
- "80:80"
- "443:443"
- "8001:5015"
command: >
bash -c "sudo redis-server /etc/redis/redis.conf
&& sudo /etc/init.d/nginx start
&& uwsgi --ini scripts/uwsgi.ini
&& daphne -b 0.0.0.0 -p 5015 acapp.asgi:application"
inx start
&& uwsgi --ini scripts/uwsgi.ini
&& daphne -b 0.0.0.0 -p 5015 acapp.asgi:application"
以上是关于配置y总docker的主要内容,如果未能解决你的问题,请参考以下文章