8
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Docker on MacでCentOS7が動かねええええという場合のメモ

Last updated at Posted at 2015-12-06

#動機
Mac OSX上でDockerを立てようとしたところ、バージョンが上がってboot2dockerからdocker-machineにバージョンが変わったけど、
うまくCentOS7が動かなかったので解決のためのメモ

##dockerの環境構築

こちらの記事参考。

##バージョン確認

$ docker -v
Docker version 1.9.0, build 76d6bc9
$  docker-machine -v
docker-machine version 0.5.0 (04cfa58)

##CentOS7のイメージpull

$ docker pull centos:latest

##pullから起動

$ docker run -it centos:latest /bin/bash
[root@fe0cd42fcf4f /]# systemctl
Failed to get D-Bus connection: No connection to service manager.

なぬー。
へんなのでたー。

##回避策

$ docker run --privileged -d -p 80:80 --name hogehoge centos:latest /sbin/init
$ docker exec -it (コンテナID) bash
[root@a0b7a6f97f01 /]# systemctl
WARNING: terminal is not fully functional
UNIT                        LOAD   ACTIVE SUB       DESCRIPTION
-.mount                     loaded active mounted   /
dev-mqueue.mount            loaded active mounted   POSIX Message Queue File Sys
etc-hostname.mount          loaded active mounted   /etc/hostname
etc-hosts.mount             loaded active mounted   /etc/hosts
etc-resolv.conf.mount       loaded active mounted   /etc/resolv.conf
(後略)

動いたみたい。

##CentOS7にNetworkManagerを動くようにする

CentOS7のくせに、なぜかnmcliが動いてない。

[root@a0b7a6f97f01 /]# cat /etc/redhat-release 
CentOS Linux release 7.1.1503 (Core) 
[root@a0b7a6f97f01 /]# nmcli
bash: nmcli: command not found

しかたないので、yumでNetworkManagerをインストールする。

[root@a0b7a6f97f01 /]# yum install NetworkManager
(後略)
Complete!

# nmcli 
Usage: nmcli [OPTIONS] OBJECT { COMMAND | help }

OPTIONS
  -t[erse]                                   terse output
  -p[retty]                                  pretty output
  -m[ode] tabular|multiline                  output mode
(後略)

# systemctl status NetworkManager
NetworkManager.service - Network Manager
   Loaded: loaded (/usr/lib/systemd/system/NetworkManager.service; enabled)
  Drop-In: /run/systemd/system/NetworkManager.service.d
           └─00-docker.conf
   Active: inactive (dead)

[root@a0b7a6f97f01 /]# 

とりあえず、インストールできたみたい。

systemctlでサービスを追加する。

[root@a0b7a6f97f01 /]# systemctl start NetworkManager
[root@a0b7a6f97f01 /]# systemctl status NetworkManager
NetworkManager.service - Network Manager
   Loaded: loaded (/usr/lib/systemd/system/NetworkManager.service; enabled)
  Drop-In: /run/systemd/system/NetworkManager.service.d
           └─00-docker.conf
   Active: active (running) since Sun 2015-12-06 10:38:56 UTC; 1s ago
 Main PID: 939 (NetworkManager)
   CGroup: /system.slice/NetworkManager.service
           └─939 /usr/sbin/NetworkManager --no-daemon

Dec 06 10:38:57 a0b7a6f97f01 NetworkManager[939]: <info>  (eth0): device stat...
Dec 06 10:38:57 a0b7a6f97f01 NetworkManager[939]: <info>  (eth0): Activation:...
Dec 06 10:38:57 a0b7a6f97f01 NetworkManager[939]: <info>  (eth0): Activation:...
Dec 06 10:38:57 a0b7a6f97f01 NetworkManager[939]: <info>  (eth0): Activation:...
Dec 06 10:38:57 a0b7a6f97f01 NetworkManager[939]: <info>  (eth0): device stat...
Dec 06 10:38:57 a0b7a6f97f01 NetworkManager[939]: <info>  (eth0): device stat...
Dec 06 10:38:57 a0b7a6f97f01 NetworkManager[939]: <info>  NetworkManager stat...
Dec 06 10:38:57 a0b7a6f97f01 NetworkManager[939]: <info>  NetworkManager stat...
Dec 06 10:38:57 a0b7a6f97f01 NetworkManager[939]: <info>  Policy set 'eth0' (...
Dec 06 10:38:57 a0b7a6f97f01 NetworkManager[939]: <info>  (eth0): Activation:...
Hint: Some lines were ellipsized, use -l to show in full.
[root@a0b7a6f97f01 /]# 

と、設定完了。しめしめ。

と、ここまでやったけど、Dockerなのでこれをイメージ化するか、

$ docker commit a0b7a6f97f01 centos7_nmcli:0.0
dc67d97eb0a777df3a99d696f2e21071e6d923f47bab137e4626d9a4ca7d0692

それともDockerfile化するか。
ふーむ。。。

まあ、とりあえず動くっぽい。

8
5
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
8
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?