The host has a changing IP address (or none if you have no network access). From 18.03 onwards our recommendation is to connect to the special DNS name host.docker.internal, which resolves to the internal IP address used by the host. This is for development purpose and will not work in a production environment outside of Docker Desktop for Mac.

The gateway is also reachable as gateway.docker.internal.

link: https://docs.docker.com/docker-for-mac/networking/

docker在制作镜像时,抛出异常:

debconf: unable to initialize frontend: Dialog
debconf: (TERM is not set, so the dialog frontend is not usable.)
debconf: falling back to frontend: Readline
debconf: unable to initialize frontend: Readline
debconf: (This frontend requires a controlling tty.)
debconf: falling back to frontend: Teletype
dpkg-preconfigure: unable to re-open stdin:

原因是因为在使用apt-get安装依赖时并非静默安装,需要交互,所以无法正常通过。

解决方法,在docker file中增加一句:

ENV DEBIAN_FRONTEND noninteractive

link: https://blog.csdn.net/a19891024/article/details/78250967

在腾讯云服务器中使用腾讯的容器服务,拉取腾讯云仓库中的镜像时,会出现如下的报错:

docker pull ccr.ccs.tencentyun.com/qcloud/nginx:1.9
Trying to pull repository ccr.ccs.tencentyun.com/qcloud/nginx ... 
1.9: Pulling from ccr.ccs.tencentyun.com/qcloud/nginx
51f5c6a04d83: Pulling fs layer 
a3ed95caeb02: Pulling fs layer 
640c8f3d0eb2: Downloading 
a4335300aa89: Waiting 
unknown blob

出现这种问题一般是dns解析问题或者https认证等问题。

dns的问题手动添加hosts即可,https问题添加如下配置到/etc/default/docker 即可:

DOCKER_OPTS="--insecure-registry ccr.ccs.tencentyun.com"

重启docker服务

systemctl restart  docker.service

重启完之后,即可正常拉取。

docker pull ccr.ccs.tencentyun.com/qcloud/nginx:1.9
Trying to pull repository ccr.ccs.tencentyun.com/qcloud/nginx ... 
1.9: Pulling from ccr.ccs.tencentyun.com/qcloud/nginx
51f5c6a04d83: Pull complete 
a3ed95caeb02: Pull complete 
640c8f3d0eb2: Pull complete 
a4335300aa89: Pull complete 
Digest: sha256:311e9840c68d889e74eefa18227d0a6f995bc7a74f5453fdcd49fe3c334feb24
Status: Downloaded newer image for ccr.ccs.tencentyun.com/qcloud/nginx:1.9

使用Docker编译Kotlin时,遇到了如下报错:

FAILURE: Build failed with an exception.

* What went wrong:
Could not create service of type ScriptPluginFactory using BuildScopeServices.createScriptPluginFactory().
> Could not create service of type CrossBuildFileHashCache using BuildSessionScopeServices.createCrossBuildFileHashCache().

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 2s

我的Dockerfile如下:

FROM gradle:5.2.1-jdk8 as builder
COPY ./ /data/dropbox/
WORKDIR /data/dropbox
RUN gradle build --no-daemon

经过排查,发现是权限问题,无法启动gradle进行编译,因此加入如下一句:

USER root

即可成功通过。完整Dockerfile如下:

FROM gradle:5.2.1-jdk8 as builder
COPY ./ /data/dropbox/
USER root
WORKDIR /data/dropbox
RUN gradle build --no-daemon