title: amazonlinux:2 systemctl Failed to get D-Bus connection
body: <p>I would like to use this image <a href="https://hub.docker.com/_/amazonlinux" rel="nofollow noreferrer">https://hub.docker.com/_/amazonlinux</a> to script my EC2 machine</p>
  
  <p>Here is my Dockefile :</p>
  
  <pre><code>FROM amazonlinux:2
  
  MAINTAINER "xxxxx" &lt;xxxxx@xxxx.xx&gt;
  
  RUN yum -y update
  RUN yum -y install httpd
  
  WORKDIR /var/www/html
  
  CMD [ "/usr/sbin/httpd","-D","FOREGROUND" ]
  </code></pre>
  
  <p>systemctl do not works :</p>
  
  <pre><code>bash-4.2# systemctl list-units
  Failed to get D-Bus connection: Operation not permitted
  </code></pre>
  
  <pre><code>bash-4.2# systemctl status httpd.service
  Failed to get D-Bus connection: Operation not permitted
  </code></pre>
  
  <p>I cannot restart</p>
  
  <pre><code>bash-4.2# systemctl restart httpd.service
  Failed to get D-Bus connection: Operation not permitted
  </code></pre>
  
  <p>/etc/os-release</p>
  
  <pre><code>bash-4.2# cat /etc/os-release
  NAME="Amazon Linux"
  VERSION="2"
  ID="amzn"
  ID_LIKE="centos rhel fedora"
  VERSION_ID="2"
  PRETTY_NAME="Amazon Linux 2"
  ANSI_COLOR="0;33"
  CPE_NAME="cpe:2.3:o:amazon:amazon_linux:2"
  HOME_URL="https://amazonlinux.com/"
  </code></pre>
  
  <p>No problem on real ec2 :</p>
  
  <pre><code>[ec2-user@ip-xxxxxxxxx]$ cat /etc/os-release
  NAME="Amazon Linux"
  VERSION="2"
  ID="amzn"
  ID_LIKE="centos rhel fedora"
  VERSION_ID="2"
  PRETTY_NAME="Amazon Linux 2"
  ANSI_COLOR="0;33"
  CPE_NAME="cpe:2.3:o:amazon:amazon_linux:2"
  HOME_URL="https://amazonlinux.com/"
  
  [ec2-user@ip-xxxxxxxxx]$ systemctl status httpd.service
  ● httpd.service - The Apache HTTP Server
     Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
    Drop-In: /usr/lib/systemd/system/httpd.service.d
             └─php-fpm.conf
     Active: active (running) since mer. 2020-05-20 16:36:19 UTC; 1h 50min ago
       Docs: man:httpd.service(8)
   Main PID: 3047 (httpd)
     Status: "Total requests: 7; Idle/Busy workers 100/0;Requests/sec: 0.00106; Bytes served/sec:  20 B/sec"
     CGroup: /system.slice/httpd.service
             ├─3047 /usr/sbin/httpd -DFOREGROUND
             ├─3075 /usr/sbin/httpd -DFOREGROUND
             ├─3076 /usr/sbin/httpd -DFOREGROUND
             ├─3077 /usr/sbin/httpd -DFOREGROUND
             ├─3078 /usr/sbin/httpd -DFOREGROUND
             ├─3079 /usr/sbin/httpd -DFOREGROUND
             └─3495 /usr/sbin/httpd -DFOREGROUND
  
  mai 20 16:36:19 xxxxxxxxx.internal systemd[1]: Starting The Apache HTTP Server...
  mai 20 16:36:19 xxxxxxxxx.internal systemd[1]: Started The Apache HTTP Server.
  
  </code></pre>
  
  <p>It's a famous image, has anyone found a solution ?</p>