我正在遵循Docker的文档来了解Docker的工作原理。
但是,我遇到一个问题,即 Doc ,
说这个命令运行时:
$ docker run -d ubuntu:14.04 / bin / sh -cwhile true; do echo hello world; sleep 1; done由于 -d 标志,启动了一个守护程序。 / p>
但是当使用 docker ps 命令检查运行容器时,它是空的,只有标题:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES使用 docker ps -a 命令查看我看到的所有容器:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES e7f1 bebd5a49 ubuntu:14.04/ bin / sh -c while tru6分钟前退出(2)4分钟前cranky_mcclintock它以错误代码2 退出。观看日志:
docker logs e7f1bebd5a49 true ;: 1:true; ...语法错误:文件结束意外为什么会发生这种情况?我在Windows 10中使用Docker(使用Docker Quickstart Terminal)。
这是我的 docker信息 :
容器:3 图片:52 服务器版本:1.9.1 存储驱动程序:aufs 根目录:/ mnt / sda1 / var / lib / docker / aufs 备份文件系统:extfs Dirs:58 Dirperm1支持:true 执行驱动程序:native-0.2 日志驱动程序:json-file 内核版本:4.1.13-boot2docker 操作系统:Boot2Docker 1.9.1(TCL 6.4.1); CPU:1 总内存:996.2 MiB 名称:默认调试模式(服务器):true 文件描述符:12 Goroutines:20 EventsListeners:0 Init SHA1:初始路径:/ usr / local / bin / docker Docker根目录:/ mnt / sda1 / var / lib / docker 注册表:index.docker.io/v1/ 标签: provider = virtualbox
这是 docker事件之后的 docker run
$ docker run -d ubuntu:14.04 / bin / sh -cwhile true; do echo hello world; sleep 1 ;完成 e7f1bebd5a490e35ce8451c5f12a4a4f4e089bd70fc6ad1726e927a0610f3e49 2016-01-14T13:20:55.350098419 + 08:00 e7f1bebd5a490e35ce8451c5f12a4a4f4e089bd70fc6ad1726e927a0610f3e49 :(从ubuntu:14.04)创建 2016-01-14T13:20: 55.363562836 + 08:00 e7f1bebd5a490e35ce8451c5f12a4a4f4e089bd70fc6ad1726e927a0610f3e49 :(从ubuntu:14.04)开始 2016-01-14T13:20:55.436727252 + 08:00 e7f1bebd5 a490e35ce8451c5f12a4a4f4e089bd70fc6ad1726e927a0610f3e49 :(从ubuntu:14.04)死解决方案
VirtualBox的控制台一切正常。它只在Windows的控制台(使用Docker快速入门终端)中失败。
我认为底层问题是使用行尾代码字符( \\\ , \r 或 \r\\\ )。
I am following Docker's docs to understand how Docker works.
But i meet a problem in that Doc,
The say that when this command is run:
$ docker run -d ubuntu:14.04 /bin/sh -c "while true; do echo hello world; sleep 1; done"a daemon is started because of the -d flag.
But when checking the running container with the docker ps command, it is empty, with just titles:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMESUsing the docker ps -a command to watch all containers I see this:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES e7f1bebd5a49 ubuntu:14.04 "/bin/sh -c while tru" 6 minutes ago Exited (2) 4 minutes ago cranky_mcclintockIt exits with error code 2. Watching the log:
docker logs e7f1bebd5a49 true;: 1: true;: Syntax error: end of file unexpectedWhy is this happening? I am running Docker in Windows 10 (using the Docker Quickstart Terminal).
This is part of my docker info:
Containers: 3 Images: 52 Server Version: 1.9.1 Storage Driver: aufs Root Dir: /mnt/sda1/var/lib/docker/aufs Backing Filesystem: extfs Dirs: 58 Dirperm1 Supported: true Execution Driver: native-0.2 Logging Driver: json-file Kernel Version: 4.1.13-boot2docker Operating System: Boot2Docker 1.9.1 (TCL 6.4.1); CPUs: 1 Total Memory: 996.2 MiB Name: default Debug mode (server): true File Descriptors: 12 Goroutines: 20 EventsListeners: 0 Init SHA1: Init Path: /usr/local/bin/docker Docker Root Dir: /mnt/sda1/var/lib/docker Registry: index.docker.io/v1/ Labels: provider=virtualbox
Here is the docker events after docker run
$ docker run -d ubuntu:14.04 /bin/sh -c "while true; do echo hello world; sleep 1; done" e7f1bebd5a490e35ce8451c5f12a4a4f4e089bd70fc6ad1726e927a0610f3e49 2016-01-14T13:20:55.350098419+08:00 e7f1bebd5a490e35ce8451c5f12a4a4f4e089bd70fc6ad1726e927a0610f3e49: (from ubuntu:14.04) create 2016-01-14T13:20:55.363562836+08:00 e7f1bebd5a490e35ce8451c5f12a4a4f4e089bd70fc6ad1726e927a0610f3e49: (from ubuntu:14.04) start 2016-01-14T13:20:55.436727252+08:00 e7f1bebd5a490e35ce8451c5f12a4a4f4e089bd70fc6ad1726e927a0610f3e49: (from ubuntu:14.04) die解决方案
When using VirtualBox's console everything works. It only fails in Windows's console (using the Docker Quickstart Terminal).
I think the underlying problem is with the end-of-line code character (\n,\r or \r\n).
更多推荐
Docker容器无法作为守护进程运行
发布评论