码头工人撰写不会建立

时间:2019-05-30 02:03:13

标签: docker docker-compose

使用docker-compose在现有的dockerfile上进行一些细微更改会生成失败,

Step 1/10 : FROM alpine:latest
 ---> 055936d39205
Step 2/10 : LABEL MAINTAINER="Peter Winter <peter@pwntr.com>"     Description="Simple and lightweight Samba docker container, based on Alpine Linux."     Version="1.0.2"
 ---> Using cache
 ---> e99eafd27cc6
Step 3/10 : RUN apk --no-cache upgrade && apk --no-cache add samba samba-common-tools supervisor
 ---> Running in 99c71d23252f
fetch http://dl-cdn.alpinelinux.org/alpine/v3.9/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.9/community/x86_64/APKINDEX.tar.gz
WARNING: Ignoring http://dl-cdn.alpinelinux.org/alpine/v3.9/main/x86_64/APKINDEX.tar.gz: could not connect to server (check repositories file)
WARNING: Ignoring http://dl-cdn.alpinelinux.org/alpine/v3.9/community/x86_64/APKINDEX.tar.gz: could not connect to server (check repositories file)
OK: 6 MiB in 14 packages
fetch http://dl-cdn.alpinelinux.org/alpine/v3.9/main/x86_64/APKINDEX.tar.gz
WARNING: Ignoring http://dl-cdn.alpinelinux.org/alpine/v3.9/main/x86_64/APKINDEX.tar.gz: could not connect to server (check repositories file)
fetch http://dl-cdn.alpinelinux.org/alpine/v3.9/community/x86_64/APKINDEX.tar.gz
WARNING: Ignoring http://dl-cdn.alpinelinux.org/alpine/v3.9/community/x86_64/APKINDEX.tar.gz: could not connect to server (check repositories file)
ERROR: unsatisfiable constraints:
  samba (missing):
    required by: world[samba]
  samba-common-tools (missing):
    required by: world[samba-common-tools]
  supervisor (missing):
    required by: world[supervisor]
ERROR: compose.cli.main.main: Service 'samba' failed to build: The command '/bin/sh -c apk --no-cache upgrade && apk --no-cache add samba samba-common-tools supervisor' returned a non-zero code: 3

似乎不使用代理?

docker-compose.yml

version: "3.7"
services:
  samba:
    #image: pwntr/samba-alpine
    build:
      context: .
      dockerfile: Dockerfile
    container_name: samba
    volumes:
      - /some/path:/shared:ro
    restart: unless-stopped

我尝试使用代理详细信息设置args和environment部分,但是没有区别。

version: "3.7"
services:
  samba:
    #image: pwntr/samba-alpine
    build:
      context: .
      dockerfile: Dockerfile
#      args: # Environment variables available at build-time
#        - http_proxy=http://127.0.0.1:3128
#        - https_proxy=http://127.0.0.1:3128
#        - HTTP_PROXY=http://127.0.0.1:3128
#        - HTTPS_PROXY=http://127.0.0.1:3128
#    environment: # Environment variables available at container run-time
#      - http_proxy=http://127.0.0.1:3128
#      - https_proxy=http://127.0.0.1:3128
#      - HTTP_PROXY=http://127.0.0.1:3128
#      - HTTPS_PROXY=http://127.0.0.1:3128
    container_name: samba
    volumes:
      - /some/path:/shared:ro
    restart: unless-stopped

如果我使用docker run或通过图像,一切正常。

version: "3.7"
services:
  samba:
    image: pwntr/samba-alpine
    container_name: samba
    volumes:
      - /some/path:/shared:ro
    restart: unless-stopped

服务器/主机正在运行Alpine Linux,并且连接正常。

docker info | grep -i proxy
HTTP Proxy: http://127.0.0.1:3128/
HTTPS Proxy: http://127.0.0.1:3128/

2 个答案:

答案 0 :(得分:0)

尝试一下 docker build -t localhost/smb:v1 .

最好将RUN apk --no-cache upgrade && apk --no-cache add samba samba-common-tools supervisor更改为RUN apk --no-cache --upgrade add samba samba-common-tools supervisor,以避免出现多个网络请求。

答案 1 :(得分:0)

以防其他人遇到问题。

运行ifconfig并找到docker0的IP地址

编辑cntlm.conf并添加以下内容

Listen 172.17.0.1:3128#docker0的IP地址

重新启动cntlm

/root/.docker/config.json创建配置文件并添加以下内容

{
 "proxies":
 {
   "default":
   {
     "httpProxy": "http://172.17.0.1:3128",
     "httpsProxy": "http://172.17.0.1:3128",
     "ftpProxy": "http://172.17.0.1:3128"
   }
 }
}