LoginSignup
3
3
新規開発や新技術の検証、導入にまつわる記事を投稿しよう!

dockerで機械学習(101) 環境構築(1) docker どっかーら、どーやってもエラーばっかり。

Last updated at Posted at 2018-10-08

OS上のdocker コマンド

「docker どっかーら、どーやってもエラーばっかり」な時、
順番に動作を確認することが大事。

また、ここに記載した事項は、順次解決しています。
ここに追記するか、関連URLの先に記載し、ここに再整理予定です。

<この項は書きかけです。順次追記します。>
This article is not completed. I will add some words in order.

dockerコマンドが導入済みか

「docker ps」で確認するとよい。

docker ps

$ docker ps
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

上記はMacでDockerアプリを起動していなかった時。

$ docker ps
Error response from daemon: dial unix vms/0/00000003.00000948: connect: connection refused

$ docker ps
Error response from daemon: Bad response from Docker engine

上記はdocker アプリは起動している。接続がうまくいっていない。

OgawaKishinoMBP:~ ogawakiyoshi$ docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES

上記はdocker psコマンドはうまく機能しているが、なにもdockerを起動していない時。

docker images

$ docker images
REPOSITORY                                              TAG                 IMAGE ID            CREATED             SIZE

まだ、何もしていない時は上記。過去の残骸がある場合は、例えば下記。

$ docker images
REPOSITORY                                              TAG                 IMAGE ID            CREATED             SIZE
kaizenjapan/anaconda2-willi                             <none>              65e195f7ae66        47 hours ago        4.5GB
<none>                                                  <none>              cd3ce6c61c89        2 days ago          5.66GB
<none>                                                  <none>              23cc27429c4b        2 days ago          5.66GB
<none>                                                  <none>              05a7a823de44        2 weeks ago         2.9GB
ubuntu                                                  14.04               c32fae490809        4 weeks ago         188MB
continuumio/anaconda3                                   <none>              a9090db7be5a        4 months ago        3.6GB
gcc                                                     <none>              8357b3fcbe41        6 months ago        1.64GB

docker rmi

もう使わないimageは消しておくとよい。

$ docker rmi  65e195f7ae66
Error response from daemon: conflict: unable to delete 65e195f7ae66 (cannot be forced) - image has dependent child images

$ docker rmi 05a3bd381fc2   
Error response from daemon: conflict: unable to delete 05a3bd381fc2 (must be forced) - image is being used by stopped container 0137e4ebe13d

$ docker rmi 0137e4ebe13d
Error: No such image: 0137e4ebe13d

docker commit

$ docker commit 5e6115003e9f kaizenjapan/anaconda-nikhil 
Error response from daemon: Error processing tar file(exit status 1): write /opt/conda/lib/python3.6/site-packages/PyQt5/Qt/lib/libQt5WebEngineCore.so.5: no space left on device

docker pull

docker pull kaizenjapan/anaconda-keras
Using default tag: latest
Error response from daemon: Get https://registry-1.docker.io/v2/kaizenjapan/anaconda-keras/manifests/latest: unauthorized: incorrect username or password

docker login

$ docker login
Authenticating with existing credentials...
Stored credentials invalid or expired
Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one.
Username (kaizen@wh.commufa.jp):      
Password: 
Error response from daemon: Get https://registry-1.docker.io/v2/: unauthorized: incorrect username or password

なぜか、Webでhub.docker.comにloginしたら入れた。

docker run

$ docker run -it -p 8888:8888 kaizenjapan/r-keras
Unable to find image 'kaizenjapan/r-keras:latest' locally
latest: Pulling from kaizenjapan/r-keras
cc1a78bfd46b: Pull complete 
314b82d3c9fe: Pull complete 
adebea299011: Extracting [==================================================>]  1.491GB/1.491GB
f7baff790e81: Download complete 
44c478e462a0: Download complete 
3adc51af53a0: Download complete 
docker: failed to register layer: Error processing tar file(exit status 1: unpigz: skipping: <stdin>: corrupted -- crc32 mismatch
): .
See 'docker run --help'.

Usage:	docker run [OPTIONS] IMAGE [COMMAND] [ARG...]

Run a command in a new container

Options:
      --add-host list                  Add a custom host-to-IP mapping (host:ip)
  -a, --attach list                    Attach to STDIN, STDOUT or STDERR
      --blkio-weight uint16            Block IO (relative weight), between 10 and 1000, or 0 to disable (default 0)
      --blkio-weight-device list       Block IO weight (relative device weight) (default [])
      --cap-add list                   Add Linux capabilities
      --cap-drop list                  Drop Linux capabilities
      --cgroup-parent string           Optional parent cgroup for the container
      --cidfile string                 Write the container ID to the file
      --cpu-period int                 Limit CPU CFS (Completely Fair Scheduler) period
      --cpu-quota int                  Limit CPU CFS (Completely Fair Scheduler) quota
      --cpu-rt-period int              Limit CPU real-time period in microseconds
      --cpu-rt-runtime int             Limit CPU real-time runtime in microseconds
  -c, --cpu-shares int                 CPU shares (relative weight)
      --cpus decimal                   Number of CPUs
      --cpuset-cpus string             CPUs in which to allow execution (0-3, 0,1)
      --cpuset-mems string             MEMs in which to allow execution (0-3, 0,1)
  -d, --detach                         Run container in background and print container ID
      --detach-keys string             Override the key sequence for detaching a container
      --device list                    Add a host device to the container
      --device-cgroup-rule list        Add a rule to the cgroup allowed devices list
      --device-read-bps list           Limit read rate (bytes per second) from a device (default [])
      --device-read-iops list          Limit read rate (IO per second) from a device (default [])
      --device-write-bps list          Limit write rate (bytes per second) to a device (default [])
      --device-write-iops list         Limit write rate (IO per second) to a device (default [])
      --disable-content-trust          Skip image verification (default true)
      --dns list                       Set custom DNS servers
      --dns-option list                Set DNS options
      --dns-search list                Set custom DNS search domains
      --entrypoint string              Overwrite the default ENTRYPOINT of the image
  -e, --env list                       Set environment variables
      --env-file list                  Read in a file of environment variables
      --expose list                    Expose a port or a range of ports
      --group-add list                 Add additional groups to join
      --health-cmd string              Command to run to check health
      --health-interval duration       Time between running the check (ms|s|m|h) (default 0s)
      --health-retries int             Consecutive failures needed to report unhealthy
      --health-start-period duration   Start period for the container to initialize before starting health-retries countdown (ms|s|m|h)
                                       (default 0s)
      --health-timeout duration        Maximum time to allow one check to run (ms|s|m|h) (default 0s)
      --help                           Print usage
  -h, --hostname string                Container host name
      --init                           Run an init inside the container that forwards signals and reaps processes
  -i, --interactive                    Keep STDIN open even if not attached
      --ip string                      IPv4 address (e.g., 172.30.100.104)
      --ip6 string                     IPv6 address (e.g., 2001:db8::33)
      --ipc string                     IPC mode to use
      --isolation string               Container isolation technology
      --kernel-memory bytes            Kernel memory limit
  -l, --label list                     Set meta data on a container
      --label-file list                Read in a line delimited file of labels
      --link list                      Add link to another container
      --link-local-ip list             Container IPv4/IPv6 link-local addresses
      --log-driver string              Logging driver for the container
      --log-opt list                   Log driver options
      --mac-address string             Container MAC address (e.g., 92:d0:c6:0a:29:33)
  -m, --memory bytes                   Memory limit
      --memory-reservation bytes       Memory soft limit
      --memory-swap bytes              Swap limit equal to memory plus swap: '-1' to enable unlimited swap
      --memory-swappiness int          Tune container memory swappiness (0 to 100) (default -1)
      --mount mount                    Attach a filesystem mount to the container
      --name string                    Assign a name to the container
      --network string                 Connect a container to a network (default "default")
      --network-alias list             Add network-scoped alias for the container
      --no-healthcheck                 Disable any container-specified HEALTHCHECK
      --oom-kill-disable               Disable OOM Killer
      --oom-score-adj int              Tune host's OOM preferences (-1000 to 1000)
      --pid string                     PID namespace to use
      --pids-limit int                 Tune container pids limit (set -1 for unlimited)
      --platform string                Set platform if server is multi-platform capable
      --privileged                     Give extended privileges to this container
  -p, --publish list                   Publish a container's port(s) to the host
  -P, --publish-all                    Publish all exposed ports to random ports
      --read-only                      Mount the container's root filesystem as read only
      --restart string                 Restart policy to apply when a container exits (default "no")
      --rm                             Automatically remove the container when it exits
      --runtime string                 Runtime to use for this container
      --security-opt list              Security Options
      --shm-size bytes                 Size of /dev/shm
      --sig-proxy                      Proxy received signals to the process (default true)
      --stop-signal string             Signal to stop a container (default "SIGTERM")
      --stop-timeout int               Timeout (in seconds) to stop a container
      --storage-opt list               Storage driver options for the container
      --sysctl map                     Sysctl options (default map[])
      --tmpfs list                     Mount a tmpfs directory
  -t, --tty                            Allocate a pseudo-TTY
      --ulimit ulimit                  Ulimit options (default [])
  -u, --user string                    Username or UID (format: <name|uid>[:<group|gid>])
      --userns string                  User namespace to use
      --uts string                     UTS namespace to use
  -v, --volume list                    Bind mount a volume
      --volume-driver string           Optional volume driver for the container
      --volumes-from list              Mount volumes from the specified container(s)
  -w, --workdir string                 Working directory inside the container

Macintosh

dockerアイコンをクリックすると次のエラーが出た。

docker-err1.png

「Diagnose & Feedback」を押すと

docker-err2.png

指定したコマンドを実行してみる。

$ /Applications/Docker.app/Contents/Resources/bin/docker-diagnose -u
macOS: version 10.12.6 (build: 16G1036)
Docker.app: version: 18.03.1-ce-mac65 (dd2831d4b7421cf559a0881cc7a5fdebeb8c2b98)
Local time: 2018年 10月 9日 火曜日 11時39分35秒 JST
UTC:        2018年 10月 9日 火曜日 02時39分35秒 UTC
Timestamp:  20181009-113935
Running diagnostic tests:
[OK]      Files
[ERROR]   Docker CLI       Connection refused (ECONNREFUSED) connecting to /var/run/docker.sock: check if service is running
[ERROR]   Docker CLI       Connection refused (ECONNREFUSED) connecting to /Users/administrator/Library/Containers/com.docker.docker/Data/s60: check if service is running
Error docker ps: timeout after 10.00s
[ERROR]   docker-cli       docker ps failed: (Failure "docker ps: timeout after 10.00s")
[OK]      Moby booted
[ERROR]   driver.amd64-linux com.docker.driver.amd64-linux is not running
[OK]      vmnetd
[ERROR]   osxfs            com.docker.osxfs is not running
[ERROR]   VPNKit           Unexpected error ((Failure
  "Error connecting socket to 9p endpoint unix:/Users/administrator/Library/Containers/com.docker.docker/Data/s51: Unix.Unix_error(Unix.ECONNREFUSED, \"connect\", \"\")")) connecting to /Users/administrator/Library/Containers/com.docker.docker/Data/s51
[ERROR]   VPNKit           com.docker.vpnkit is not running
Error docker ps: got timeout (docker ps: exit 1)

docker-err3.png

docker-err5.png

docker-err6.png

原因は分からず。再度diagnose

$ /Applications/Docker.app/Contents/Resources/bin/docker-diagnose -u
macOS: version 10.12.6 (build: 16G1036)
Docker.app: version: 18.03.1-ce-mac65 (dd2831d4b7421cf559a0881cc7a5fdebeb8c2b98)
Local time: 2018年 10月 9日 火曜日 11時51分17秒 JST
UTC:        2018年 10月 9日 火曜日 02時51分17秒 UTC
Timestamp:  20181009-115117
Running diagnostic tests:
[OK]      Files
[ERROR]   Docker CLI       cannot find docker
[ERROR]   Docker CLI       /var/run/docker.sock does not exist
[ERROR]   Docker CLI       Unexpected error (No such file or directory) connecting to /var/run/docker.sock
[ERROR]   Docker CLI       /Users/administrator/Library/Containers/com.docker.docker/Data/s60 does not exist
[ERROR]   Docker CLI       Unexpected error (No such file or directory) connecting to /Users/administrator/Library/Containers/com.docker.docker/Data/s60
Error docker ps: timeout after 10.00s
[ERROR]   docker-cli       docker ps failed: (Failure "docker ps: timeout after 10.00s")
[ERROR]   Moby booted      /Users/administrator/Library/Containers/com.docker.docker/Data/vms/0/console-ring does not exist
[ERROR]   driver.amd64-linux com.docker.driver.amd64-linux is not running
[ERROR]   vmnetd           /var/tmp/com.docker.vmnetd.socket does not exist
[ERROR]   vmnetd           Unexpected error (No such file or directory) connecting to /var/tmp/com.docker.vmnetd.socket
[ERROR]   vmnetd           /private/tmp/vmnetd/com.docker.vmnetd is not running
[ERROR]   osxfs            com.docker.osxfs is not running
[ERROR]   VPNKit           Unexpected error ((Failure
  "Error connecting socket to 9p endpoint unix:/Users/administrator/Library/Containers/com.docker.docker/Data/s51: Unix.Unix_error(Unix.ENOENT, \"connect\", \"\")")) connecting to /Users/administrator/Library/Containers/com.docker.docker/Data/s51
[ERROR]   VPNKit           com.docker.vpnkit is not running
Error docker ps: got timeout (docker ps: exit 127)
[ERROR]   disk             No Docker.qcow2 or Docker.raw found: the VM has never been started
[OK]      environment
[OK]      Docker
[OK]      VT-x
[OK]      kern.hv_support
Most specific failure is: No Docker.qcow2 or Docker.raw found: the VM has never been started
Docker logs are being collected into /tmp/「なんやらいっぱい数字がならんでる。」/20181009-115117.tar.gz
Your unique id is: 「なんやらいっぱい数字がならんでる。」
Please quote this in all correspondence.
$ /Applications/Docker.app/Contents/Resources/bin/docker-diagnose -u
macOS: version 10.12.6 (build: 16G1036)
Docker.app: version: 18.03.1-ce-mac65 (dd2831d4b7421cf559a0881cc7a5fdebeb8c2b98)
Local time: 2018年 10月 9日 火曜日 11時58分28秒 JST
UTC:        2018年 10月 9日 火曜日 02時58分28秒 UTC
Timestamp:  20181009-115828
Running diagnostic tests:
[OK]      Files
[OK]      Docker CLI
[OK]      Moby booted
[OK]      driver.amd64-linux
[OK]      vmnetd
[OK]      osxfs
[OK]      VPNKit
[OK]      disk
[OK]      environment
[OK]      Docker
[OK]      VT-x
[OK]      kern.hv_support
Docker logs are being collected into /tmp/「なんやらいっぱい数字がならんでる。」/20181009-115828.tar.gz
Your unique id is: 「「なんやらいっぱい数字がならんでる。」」
Please quote this in all correspondence.

Windows

Docker for Windows
https://qiita.com/kaizen_nagoya/items/c4daa5cf52e9f0c2c002

システム管理者権限
Hyper-Vの設定
ネットワークの設定(セキュリティ)
BIOSの設定
など掲載しています。

#参考文献(reference)

Dockerでホストとコンテナ間でのファイルコピー
https://qiita.com/gologo13/items/7e4e404af80377b48fd5

docker 入門
https://qiita.com/kaizen_nagoya/items/2f31319e40ddaa0bf8a5

<この記事は個人の過去の経験に基づく個人の感想です。現在所属する組織、業務とは関係がありません。>
<This article is an individual impression based on the individual's experience. It has nothing to do with the organization or business to which I currently belong. >
#文書履歴(document history)
ver. 0.10 初稿 20181008
ver. 0.11 commit 追記 20181009 朝
ver. 0.12 windows, Mac 追記 20181009 午前
ver. 0.13 docker hub 追記 20181009 昼
ver. 0.14 エラーの対処方法などを追記中 20181010
ver. 0.15 説明を追記 20181011
ver. 0.16 番号変更、参考文献追記 20181027
ver. 0.17 docker run error追記 20181028

最後までおよみいただきありがとうございました。

いいね 💚、フォローをお願いします。

Thank you very much for reading to the last sentence.

Please press the like icon 💚 and follow me for your happy life.

3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3