当我想在 Windows 上构建我的图像时,我正面临一个奇怪的问题。我没有将Docker用于其他任何用途,因此可以认为安装是全新的。根本没有卷,也没有图像。
当我尝试从我的 Dockerfile 构建我的应用程序时,它以这个错误结束
docker build ./
Sending build context to Docker daemon 1.4 GB
Error response from daemon: Error processing tar file(exit status 1): write /.bowerrc: no space left on device
Run Code Online (Sandbox Code Playgroud)
我读过你可以增加 docker 的 basesize,但我还没有找到适用于 Windows 的解决方案(为什么这在默认情况下甚至受到限制?)
docker info 打印一些东西,但它根本没有显示“存储驱动程序”下的基本大小
$ docker info
Containers: 0
Running: 0
Paused: 0
Stopped: 0
Images: 0
Server Version: 1.13.1
Storage Driver: overlay2
Backing Filesystem: tmpfs
Supports d_type: true
Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs …Run Code Online (Sandbox Code Playgroud) 我在 Dockerfile 中有以下说明
ENV DB_CONN_STRING="Data Source=DbServer;Initial Catalog=Db;User ID=sa;Password=p@ssw0rd"
ENTRYPOINT []
CMD ["powershell", "c:\\RunAll.ps1 -NewConnString", "$DB_CONN_STRING"]
Run Code Online (Sandbox Code Playgroud)
当我运行此命令时
docker run --rm -d -e DB_CONN_STRING="Test" test
Run Code Online (Sandbox Code Playgroud)
DB_CONN_STRING 在 RunAll.ps1 中始终为空。如何将 ENV 传递给 CMD?
当我使用不带参数的 CMD 时
CMD ["powershell", "c:\\RunAll.ps1"]
Run Code Online (Sandbox Code Playgroud)
一切正常。
RunAll.ps1 代码:
param(
[string]$NewConnString = "Data Source=DbServer;Initial Catalog=db;User ID=sa;Password=p@ssw0rd"
)
New-Item "C:\start_log.txt" -type file -force -value $NewConnString
.\ChangeConnString.ps1 -NewConnString $NewConnString
New-Item "C:\end_log.txt" -type file -force -value $NewConnString
# Run IIS container entry point
.\ServiceMonitor.exe w3svc
Run Code Online (Sandbox Code Playgroud)
我尝试了几种方法,exec 和 shell 命令样式、$DB_CONN_STRING、${DB_CONN_STRING} 和 $(DB_CONN_STRING) 样式。
尝试了这些帖子中的建议: …
我有一个简单的Dockerfile:
FROM php:7.1-apache
LABEL maintainer="rburton@agsource.com"
COPY C:/Users/rburton/code/MyAgsourceAPI /var/www
Run Code Online (Sandbox Code Playgroud)
这是给我麻烦的最后一行。我正在从Windows结构复制到docker容器(我假设是Linux)。构建此图像时,我得到:
...
Step 3/3 : COPY C:/Users/rburton/code/MyAgsourceAPI /var/www
COPY failed: stat /var/lib/docker/tmp/dockerbuilder720374851/C:/Users/rburton/code/MyAgsourceAPI: no such file or directory
Run Code Online (Sandbox Code Playgroud)
首先,有些事情阻止了人们认识到这是一个绝对路径,并且自然地,如果该路径前面加上/var/lib/docker/tmp/dockerbuilder720374851了前缀,则将找不到该文件。其次,我已经尝试过了/,\但是所有结果都相同。另外我怀疑的驱动器号使docker感到困惑。因此,问题是如何将文件和文件夹(以及内容)从Windows文件夹复制到Docker容器?
我构建并运行了一个 docker 镜像
docker run --detach --name api rkevinburton/myagsourceapi
Run Code Online (Sandbox Code Playgroud)
但是当我 'docker ps -a' 时,我收到一条消息,该容器已退出。
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
ee956fbf1d7f rkevinburton/myagsourceapi "/bin/bash" 10 seconds ago Exited (0) 8 seconds ago api
Run Code Online (Sandbox Code Playgroud)
所以我想找出它退出的原因。所以我发出命令
docker logs ee
Run Code Online (Sandbox Code Playgroud)
但是这个命令什么都不返回。由于 docker 主机是一台 Windows 机器,我查看了 ~\AppData\Local\Docker,但 log*.txt 或 install-log.* 中的信息似乎对我没有任何帮助。如何获得有关容器“退出”原因的更多信息?
我正在尝试组合一个可以运行 .NET 构建的 Windows Docker 容器。鉴于我需要的依赖项,最好的方法似乎是使用 Chocolatey。但是,在 Chocolatey 的安装步骤中,我在尝试运行命令时遇到下载超时
Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
Run Code Online (Sandbox Code Playgroud)
完整的错误如下。
Exception calling "DownloadString" with "1" argument(s): "The operation has
timed out"
At C:\install.ps1:3 char:51
+ ... ess -Force; iex ((New-Object System.Net.WebClient).DownloadString('ht ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], ParentContainsErrorRecordE
xception
+ FullyQualifiedErrorId : WebException
Run Code Online (Sandbox Code Playgroud)
由于多种原因,这似乎很奇怪。
结论:似乎存在某种与 Docker 相关的网络问题,它不会阻止连接到 Chocolatey.org …
我正在docker-for-windows我的私人电脑上进行设置。
当我不久前在我的办公室笔记本电脑上设置它时,我遇到了同样的问题,但它刚刚停止发生。
所以我坚持这个:
我有一个 docker-working 项目(在我的另一台计算机上),docker-compose.yml如下所示:
version: '2'
services:
web:
depends_on:
- db
build: .
env_file: ./docker-compose.env
command: bash ./run_web_local.sh
volumes:
- .:/srv/project
ports:
- 8001:8001
links:
- db
- rabbit
restart: always
Run Code Online (Sandbox Code Playgroud)
Dockerfile:
### STAGE 1: Build ###
# We label our stage as 'builder'
FROM node:8-alpine as builder
RUN npm set progress=false && npm config set depth 0 && npm cache clean --force
# build backend
ADD package.json /tmp/package.json
ADD package-lock.json /tmp/package-lock.json
RUN cd …Run Code Online (Sandbox Code Playgroud) 我有 Windows 10 Pro 和 Docker for Windows v18.06.1-ce,启用了 kubernetes。
使用kubectl create -f,我创建了 rc.yml:
apiVersion: v1
kind: ReplicationController
metadata:
name: hello-rc
spec:
replicas: 9
selector:
app: hello-world
template:
metadata:
labels:
app: hello-world
spec:
containers:
- name: hello-ctr
image: nigelpoulton/pluralsight-docker-ci:latest
ports:
- containerPort: 8080
Run Code Online (Sandbox Code Playgroud)
svc.yml
apiVersion: v1
kind: Service
metadata:
name: hello-svc
labels:
app: hello-world
spec:
type: NodePort
ports:
- port: 8080
nodePort: 30001
protocol: TCP
selector:
app: hello-world
Run Code Online (Sandbox Code Playgroud)
我希望 localhost:8080 可以工作,但它不是,10.108.96.27:8080 也不是
> kubectl describe service/hello-svc
Name: …Run Code Online (Sandbox Code Playgroud) 我已经成功构建了 Docker 镜像并在 Docker swarm 中运行它们。当我尝试构建映像并使用 Docker Desktop 的 Kubernetes 集群运行它时:
docker build -t myimage -f myDockerFile .
Run Code Online (Sandbox Code Playgroud)
(以上成功在docker本地注册表中创建了一个镜像)
kubectl run myapp --image=myimage:latest
Run Code Online (Sandbox Code Playgroud)
(据我了解,这和使用 kubectl create 部署命令是一样的)
上面的命令成功创建了一个部署,但是当它创建一个pod时,pod状态总是显示:
NAME READY STATUS RESTARTS AGE
myapp-<a random alphanumeric string> 0/1 ImagePullBackoff 0 <age>
Run Code Online (Sandbox Code Playgroud)
我不确定为什么它在拉取图像时遇到问题 - 它可能不知道 docker 本地图像在哪里?
我正在尝试使用 docker windows container构建图像。这是我的 dockerfile
FROM mcr.microsoft.com/windows/servercore:ltsc2019 as installer
RUN Invoke-WebRequest -URI 'www.google.com'
Run Code Online (Sandbox Code Playgroud)
当我运行它时,它无法连接到 google.com
Invoke-WebRequest : The remote name could not be resolved: 'www.google.com'
At line:1 char:73
Run Code Online (Sandbox Code Playgroud)
我在公司网络上工作,我尝试使用设置代理
RUN netsh winhttp set proxy proxy-server="http://proxy.com:80" bypass-list="*.xyz.com"
并导入了注册表HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings
我的容器内的 ipconfig /all 给出以下结果
Windows IP Configuration
Host Name . . . . . . . . . . . . : 0d5119fe9ce4
Primary Dns Suffix . . . . . . . :
Node Type . . . . …Run Code Online (Sandbox Code Playgroud) 在 Windows 10 Home 上使用 Docker 工具箱,Docker 版本 19.03,我们创建了一个docker-compose.yml并添加了一个机密文件作为 JSON,它在 Mac 系统上运行良好,但无法在 Windows 10 Home 中运行。
运行后报错docker-compose up:
ERROR: for orthancserver Cannot create container for service orthanc: invalid mount config for type
"bind": invalid mount path: 'C:/Users/ABC/Desktop/Project/orthanc.json' mount path must be absolute
Run Code Online (Sandbox Code Playgroud)
docker-compose.yml:
version: "3.7"
services:
orthanc:
image: jodogne/orthanc-plugins:1.6.1
command: /run/secrets/
container_name: orthancserver
restart: always
ports:
- "4242:4242"
- "8042:8042"
networks:
- mynetwork
volumes:
- /tmp/orthanc-db/:/var/lib/orthanc/db/
secrets:
- orthanc.json
dcserver:
build: ./dc_node_server
depends_on:
- orthanc …Run Code Online (Sandbox Code Playgroud) docker docker-compose docker-toolbox docker-for-windows orthanc-server