Unos de los primeros problemas que encontre con Docker es que cuando queria iniciar servicios en un sistema que utilizara systemd en lugar del viejo init.d daba el siguiente error:

[root@e8c87e7efdd4 /]# systemctl start httpd
Failed to get D-Bus connection: Operation not permitted
[root@e8c87e7efdd4 /]# 

 

Para solucionarlo primero ejecutamos:

[root@4505f0166db1 /]# yum update -y && yum install -y initscripts

Eso nos dara una salida de todos los paquetes que se actualizaran e instalaran que por tema de espacio voy a omitir aquí, luego vamos asignar un password al usuario root, ya vamos a ver porque mas adelante:

[root@e8c87e7efdd4 /]# passwd root
Changing password for user root.
New password: 
BAD PASSWORD: The password is shorter than 8 characters
Retype new password: 
passwd: all authentication tokens updated successfully.

Los mensajes anteriores fue porque elegi como contraseña «root», ahora ejecutamos la magia:

[root@4505f0166db1 /]# exec /usr/sbin/init

Eso nos dara una salida como la siguiente:

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 <a438a0349d08>.
[  OK  ] Created slice Root Slice.
[  OK  ] Created slice System Slice.
[  OK  ] Reached target Remote File Systems.
[  OK  ] Created slice User and Session Slice.
[  OK  ] Reached target Slices.
[  OK  ] Listening on Journal Socket.
         Starting Journal Service...
         Mounting FUSE Control File System...
         Mounting Huge Pages File System...
[  OK  ] Reached target Swap.
[  OK  ] Created slice system-getty.slice.
[  OK  ] Listening on /dev/initctl Compatibility Named Pipe.
         Starting Load/Save Random Seed...
[  OK  ] Reached target Encrypted Volumes.
[  OK  ] Reached target Local File Systems (Pre).
         Starting Configure read-only root support...
[  OK  ] Listening on Delayed Shutdown Socket.
         Starting Rebuild Hardware Database...
[  OK  ] Mounted FUSE Control File System.
[  OK  ] Started Journal Service.
[  OK  ] Started Load/Save Random Seed.
         Starting Flush Journal to Persistent Storage...
[  OK  ] Mounted Huge Pages File System.
[  OK  ] Started Configure read-only root support.
[  OK  ] Reached target Local File Systems.
         Starting Mark the need to relabel after reboot...
         Starting Rebuild Journal Catalog...
[  OK  ] Started Mark the need to relabel after reboot.
[  OK  ] Started Rebuild Journal Catalog.
[  OK  ] Started Flush Journal to Persistent Storage.
         Starting Create Volatile Files and Directories...
[  OK  ] Started Create Volatile Files and Directories.
         Starting Update UTMP about System Boot/Shutdown...
[  OK  ] Started Update UTMP about System Boot/Shutdown.
[  OK  ] Started Rebuild Hardware Database.
         Starting Update is Completed...
[  OK  ] Started Update is Completed.
[  OK  ] Reached target System Initialization.
[  OK  ] Reached target Paths.
[  OK  ] Listening on D-Bus System Message Bus Socket.
[  OK  ] Reached target Sockets.
[  OK  ] Reached target Basic System.
         Starting LSB: Bring up/down networking...
[  OK  ] Started D-Bus System Message Bus.
         Starting D-Bus System Message Bus...
         Starting Permit User Sessions...
         Starting Login Service...
[  OK  ] Reached target Timers.
[FAILED] Failed to start LSB: Bring up/down networking.
See 'systemctl status network.service' for details.
         Starting Cleanup of Temporary Directories...
[  OK  ] Reached target Network.
[  OK  ] Reached target Network is Online.
[  OK  ] Started Permit User Sessions.
[  OK  ] Started Console Getty.
         Starting Console Getty...
[  OK  ] Reached target Login Prompts.
[  OK  ] Started Cleanup of Temporary Directories.
[  OK  ] Started Login Service.
[  OK  ] Reached target Multi-User System.
         Starting Update UTMP about System Runlevel Changes...
[  OK  ] Started Update UTMP about System Runlevel Changes.

CentOS Linux 7 (Core)
Kernel 4.15.6-300.fc27.x86_64 on an x86_64

a438a0349d08 login: 

Finalmente nos pedirá la contraseña de root, por eso mismo se las hice cambiar mas temprano, luego de logearnos, ahora ya podremos usar service o systemcrl para reiniciar servicios.


CentOS Linux 7 (Core)
Kernel 4.15.6-300.fc27.x86_64 on an x86_64

a438a0349d08 login: root
Password: 
[root@a438a0349d08 ~]# service httpd restart
Redirecting to /bin/systemctl restart httpd.service                
[root@a438a0349d08 ~]# systemctl restart httpd
[root@a438a0349d08 ~]# 

Les puede dar error por como fuera creado la imagen, el comando para crear la maquina que use fue

#Crear la maquina
docker run -it --name=DockerTest --cap-add=SYS_ADMIN -e "container=docker" -v /sys/fs/cgroup:/sys/fs/cgroup:ro --tmpfs /run --tmpfs /run/lock centos:latest 

#Para apagarla uso el comando halt

#Para ejecutarla luego
docker start DockerTest && docker attach DockerTest

#Para apagarla de nuevo el comando halt

Deja un comentario

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *