2016-04-14 18 views
6

(. Io sono un principiante Docker Poi ho seguito alcuni tutorial per CentOS-7)Docker (CentOS 7 con systemctl): Impossibile montare tmpfs & cgroup

Nel mio CentOS 7.2, ho cercato di imparare Docker seguendo i passaggi seguenti.

# docker version 

Client: 
Version:  1.10.3 
API version: 1.22 
Go version: go1.5.3 
Git commit: 20f81dd 
Built:  Thu Mar 10 15:39:25 2016 
OS/Arch:  linux/amd64 

Server: 
Version:  1.10.3 
API version: 1.22 
Go version: go1.5.3 
Git commit: 20f81dd 
Built:  Thu Mar 10 15:39:25 2016 
OS/Arch:  linux/amd64 

# docker pull centos:latest 
# docker images 
centos  latest 778a53015523 12 days ago 196.7 MB 

# mkdir ~/docker/centos7-systemd 
# cd ~/docker/centos7-systemd 
# vi Dockerfile 
FROM centos 
MAINTAINER "XXXX XXXX" <[email protected]> 
ENV container docker 
RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == systemd-tmpfiles-setup.service ] || rm -f $i; done); \ 
rm -f /lib/systemd/system/multi-user.target.wants/*;\ 
rm -f /etc/systemd/system/*.wants/*;\ 
rm -f /lib/systemd/system/local-fs.target.wants/*; \ 
rm -f /lib/systemd/system/sockets.target.wants/*udev*; \ 
rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \ 
rm -f /lib/systemd/system/basic.target.wants/*;\ 
rm -f /lib/systemd/system/anaconda.target.wants/*; 
VOLUME [ "/sys/fs/cgroup" ] 
CMD ["/usr/sbin/init"] 

# docker build --rm -t local/centos7-systemd . 
.. 
Successfully built 1a9f1c4938b3 

# docker images 
centos     latest 778a53015523 12 days ago 196.7 MB 
local/centos7-systemd latest 1a9f1c4938b3 8 seconds ago 196.7 MB 

Quindi, fino a questo punto, tutto (sembra) ok.
Ora il problema viene quando corro:

# docker run -ti -v /sys/fs/cgroup:/sys/fs/cgroup:ro -p 80:80 local/centos7-systemd 
Failed to mount tmpfs at /run: Operation not permitted 
Failed to mount cgroup at /sys/fs/cgroup/systemd: Operation not permitted 
[!!!!!!] Failed to mount API filesystems, freezing. 

Cosa significa anche, e soprattutto, cosa sta succedendo e come posso risolvere questo problema, si prega di?

grazie a tutti voi :)

risposta

10

tenta di eseguire il vostro contenitore in modalità privilegiata:

docker run -ti --privileged=true -v /sys/fs/cgroup:/sys/fs/cgroup:ro -p 80:80 local/centos7-systemd 

questo dovrebbe risolvere il tuo problema

+0

Funziona davvero! Grazie mille!! (E hai qualche idea quando corro, perché non funziona in background, ma è sul mio terminale.) Scusa, non so come spiegarlo. Grazie ancora: D –

+2

Oh l'ho già scoperto. Devo usare l'opzione '-d'! Grazie! –

+0

prego. – arcticless

3

ho seguito

docker run -ti --privileged=true -v /sys/fs/cgroup:/sys/fs/cgroup:ro -p 80:80 local/centos7-systemd 

e venire con

Failed to insert module 'autofs4' 
Failed to mount cgroup at /sys/fs/cgroup/systemd: No such file or directory 
systemd 219 running in system mode. (+PAM +AUDIT +SELINUX +IMA -APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ -LZ4 -SECCOMP +BLKID +ELFUTILS +KMOD +IDN) 
Detected virtualization docker. 
Detected architecture x86-64. 

Welcome to CentOS Linux 7 (Core)! 

Set hostname to <c7b8edb49c60>. 
Initializing machine ID from random generator. 
Cannot determine cgroup we are running in: No such file or directory 
Failed to allocate manager object: No such file or directory 
[!!!!!!] Failed to allocate manager object, freezing. 

chiedendo che non funzioni su MacOS?

2

ho avuto lo stesso problema con Docker per Windows (1.12.3) ...

$ docker logs bareos 
systemd 219 running in system mode. (+PAM +AUDIT +SELINUX +IMA -APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ -LZ4 -SECCOMP +BLKID +ELFUTILS +KMOD +IDN) 
Detected virtualization docker. 
Detected architecture x86-64. 

Welcome to CentOS Linux 7 (Core)! 

Set hostname to <bareos>. 
Failed to install release agent, ignoring: No such file or directory 
Failed to create root cgroup hierarchy: No such file or directory 
Failed to allocate manager object: No such file or directory 
[!!!!!!] Failed to allocate manager object, freezing. 

L'ultima boot2docker non dispone systemd. Non possiamo avere systemd in un contenitore Docker, se l'host non ce l'ha. Poiché la cartella importante è /sys/fs/cgroup/systemd.

Quindi, infine, creo un vm default in VitualBox basato su Alpine Linux e uno defaultdocker-machine con il driver generic.

0

MacOS X non richiede di montare il volume cgroups nel container

$docker run -it -p 80:80 ${ImageID} 

Dopo l'esecuzione di molti casi di container, il mio mac bloccato in

[!!!!!!] Failed to mount API filesystems, freezing.

reference modalità Attualmente bash sta lavorando bene per me

$docker run -it -p 80:80 ${ImageID} /bin/bash

Problemi correlati