docker-compose初次搭建helloworld


搭建

已经同时安装了 Docker Engine 和 Docker Compose

docker-compose version

docker-compose version 1.25.5, build 8a1c60f6
docker-py version: 4.1.0
CPython version: 3.7.5
OpenSSL version: OpenSSL 1.1.0l 10 Sep 2019

 

项目所需文件及内容参考官方文档(开始使用 Docker Compose |Docker 文档

  1. app.py

  2. Dockerfile

  3. docker-compose.yml
  4. requirements.txt

开始构建

docker-compose up

ERROR: Version in “./docker-compose.yml” is unsupported. You might be seeing this error because you’re using the wrong Compose file version. Either specify a supported version (e.g “2.2” or “3.3”) and place your service definitions under the `services` key, or omit the `version` key and place your service definitions at the root of the file to use version 1.
For more on the Compose file format versions, see https://docs.docker.com/compose/compose-file/

原因:1.25的compose版本不支持3.9版本yml

solution:修改docker-compose.yml文件中版本号为3.3、修改后继续docker-compose up

 

 

ERROR: unable to select packages:
gcc (no such package):
required by: world[gcc]
linux-headers (no such package):
required by: world[linux-headers]
musl-dev (no such package):
required by: world[musl-dev]

ERROR: Service ‘web’ failed to build: The command ‘/bin/sh -c apk add –no-cache gcc musl-dev linux-headers’ returned a non-zero code: 3

 

原因:新建容器如法联网

solution:用以下命令修改配置文件以启用ipv4转发

echo 1 > /proc/sys/net/ipv4/ip_forward

sysctl -w net.ipv4.ip_forward=1

sysctl -p /etc/sysctl.conf

 

WARNING: You are using pip version 21.2.4; however, version 22.1.2 is available.
You should consider upgrading via the ‘/usr/local/bin/python -m pip install –upgrade pip’ command.
ERROR: Service ‘web’ failed to build: The command ‘/bin/sh -c pip install -r requirements.txt’ returned a non-zero code: 2

 

原创文章,作者:sunnyman218,如若转载,请注明出处:https://blog.ytso.com/tech/pnotes/271646.html

(0)
上一篇 2022年7月5日 15:04
下一篇 2022年7月5日 15:04

相关推荐

发表回复

登录后才能评论