Detailed explanation of the solution to the error of using systemctl to start the service in docker

Detailed explanation of the solution to the error of using systemctl to start the service in docker

Docker version:

[root@localhost gae_proxy]# docker version
Client:
 Version: 1.10.3
 API version: 1.22
 Package version: docker-common-1.10.3-46.el7.centos.10.x86_64
 Go version: go1.6.3
 Git commit: d381c64-unsupported
 Built: Thu Aug 4 13:21:17 2016
 OS/Arch: linux/amd64

Server:
 Version: 1.10.3
 API version: 1.22
 Package version: docker-common-1.10.3-46.el7.centos.10.x86_64
 Go version: go1.6.3
 Git commit: d381c64-unsupported
 Built: Thu Aug 4 13:21:17 2016
 OS/Arch: linux/amd64

Image version

[root@b2ca5610d3da /]# cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core) 

When starting the service through systemctl in docker, an error message such as Failed to get D-Bus connection: Operation not permitted is always reported.

[root@25d27693a24d ~]# systemctl start sshd
Failed to get D-Bus connection: Operation not permitted

The solution is to run /usr/sbin/init when docker run. for example:

[root@localhost /]# docker run -tid --name hadoopbase centos/hadoopbase:v001 /usr/sbin/init

The container that is running in this way can use systemctl to start the service. Some people say that the problem of error when running through systemctl has been solved in CentOS7.2, but I still encounter such a problem in actual operation.

Another solution is to execute the /usr/sbin/init command through CMD when generating the image file through Dockerfile, that is: CMD ["/usr/sbin/init"];

Reference: https://github.com/docker/docker/issues/7459
https://github.com/docker/docker/issues/2296

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • Setting up Docker proxy under CentOS 7 (environment variable configuration of Systemd service under Linux)
  • Use of docker system command set

<<:  Detailed explanation of Mysql's method of optimizing order by statement

>>:  How to run JavaScript in Jupyter Notebook

Recommend

Detailed tutorial on distributed operation of jmeter in docker environment

1. Build the basic image of jmeter The Dockerfile...

Innodb system table space maintenance method

Environmental Description: There is a running MyS...

Install and build a server environment of PHP+Apache+MySQL on CentOS

Yum (full name Yellow dog Updater, Modified) is a...

JS uses the reduce() method to process tree structure data

Table of contents definition grammar Examples 1. ...

Implementation of React star rating component

The requirement is to pass in the rating data for...

Detailed explanation of Vite's new experience

What is Vite? (It’s a new toy on the front end) V...

MariaDB under Linux starts with the root user (recommended)

Recently, due to the need to test security produc...

mysql method to recursively search for all child nodes of a menu node

background There is a requirement in the project ...

Real-time refresh of long connection on Vue+WebSocket page

Recently, the Vue project needs to refresh the da...

An example of the calculation function calc in CSS in website layout

calc is a function in CSS that is used to calcula...

Graphical explanation of the solutions for front-end processing of small icons

Preface Before starting this article, let’s do a ...

Automatically log out inactive users after login timeout in Linux

Method 1: Modify the .bashrc or .bash_profile fil...

Detailed example of jQuery's chain programming style

The implementation principle of chain programming...

Thirty HTML coding guidelines for beginners

1. Always close HTML tags In the source code of p...