Unable to start the postfix service on running docker container

Dears,

My requirement is to create a docker container for email server, the main task of email container is to send an email with an attachment.

I’ve created a container , in that installed postfix, but unable to start the postfix service, getting the following error, please help me to fix this issue.

224a09c3e2e6 built on rockylinux 9 version and the rhel8 is the base machine

[root@test1 docker-project]# docker exec -it 224a09c3e2e6 /bin/bash
bash-4.4# systemctl status postfix
System has not been booted with systemd as init system (PID 1). Can’t operate.
Failed to connect to bus: Host is down
bash-4.4#

Thank you in advance.

Regards, Ramachandra

Have you looked into containerized full self-hosted mail services like mailu, iredmail and postal?

1 Like

I’ve installed postfix using Dockerfile

cat Dockerfile

FROM rockylinux:9

RUN yum install postfix -y
Post that unable to start the postfix service

Well, error says postfix needs systemd.

Systemd is now included in the rockylinux/rockylinux:latest base containers, but it is not active by default.

Doc

You can’t install everything in containers that you would normally use on your host, so @bluepuma77 is right. You need to choose a mailserver optimized for containers.

Hi @bluepuma77 and @rimelek,

Thank you so much for you time and response.

Actually, I’m struggling to configure the mail agent on one of the AWX container.

I’ve installed AWX version 17 on one of RHEL8 server

Here, awx_task container is responsible to send a email notification when playbook started/success/failure.

But, in one of our requirement is that the playbook itself is having an requirement to send an email with an attachment, playbook is executed successfully but not received an email with an attachment, where all the tasks are performed by awx_task container

But, not getting how awx_task container is sending a email notification when playbook started/failed or success

I’m attaching the docker-compose.yml file for reference, please review and help me to fulfill the above requirement (to send an email with an attachment)

[root@lenltrain1d01 awxcompose]# cat docker-compose.yml
version: '2'
services:
  web:
    image: ansible/awx:17.1.0
    container_name: awx_web
    depends_on:
      - redis
      - postgres
    ports:
      - "80:8052"
    hostname: awxweb
    user: root
    restart: unless-stopped
    volumes:
      - supervisor-socket:/var/run/supervisor
      - rsyslog-socket:/var/run/awx-rsyslog/
      - rsyslog-config:/var/lib/awx/rsyslog/
      - "/var/lib/awx/awxcompose/SECRET_KEY:/etc/tower/SECRET_KEY"
      - "/var/lib/awx/awxcompose/environment.sh:/etc/tower/conf.d/environment.sh"
      - "/var/lib/awx/awxcompose/credentials.py:/etc/tower/conf.d/credentials.py"
      - "/var/lib/awx/awxcompose/nginx.conf:/etc/nginx/nginx.conf:ro"
      - "/var/lib/awx/awxcompose/redis_socket:/var/run/redis/:rw"
      - "/var/lib/awx/projects:/var/lib/awx/projects:rw"
    environment:
      http_proxy:
      https_proxy:
      no_proxy:

  task:
    image: ansible/awx:17.1.0
    container_name: awx_task
    depends_on:
      - redis
      - web
      - postgres
    command: /usr/bin/launch_awx_task.sh
    hostname: awx
    user: root
    restart: unless-stopped
    volumes:
      - supervisor-socket:/var/run/supervisor
      - rsyslog-socket:/var/run/awx-rsyslog/
      - rsyslog-config:/var/lib/awx/rsyslog/
      - "/var/lib/awx/awxcompose/SECRET_KEY:/etc/tower/SECRET_KEY"
      - "/var/lib/awx/awxcompose/environment.sh:/etc/tower/conf.d/environment.sh"
      - "/var/lib/awx/awxcompose/credentials.py:/etc/tower/conf.d/credentials.py"
      - "/var/lib/awx/awxcompose/redis_socket:/var/run/redis/:rw"
      - "/var/lib/awx/projects:/var/lib/awx/projects:rw"
      - "/data:/data:rw"
    environment:
      POSTFIX_ENABLED: "1"
      AWX_SKIP_MIGRATIONS: "1"
      http_proxy:
      https_proxy:
      no_proxy:
      SUPERVISOR_WEB_CONFIG_PATH: '/etc/supervisord.conf'

  redis:
    image: redis
    container_name: awx_redis
    restart: unless-stopped
    environment:
      http_proxy:
      https_proxy:
      no_proxy:
    command: ["/usr/local/etc/redis/redis.conf"]
    volumes:
      - "/var/lib/awx/awxcompose/redis.conf:/usr/local/etc/redis/redis.conf:ro"
      - "/var/lib/awx/awxcompose/redis_socket:/var/run/redis/:rw"

  postgres:
    image: postgres:12
    container_name: awx_postgres
    restart: unless-stopped
    volumes:
      - "/var/lib/awx/pgdocker/12/data/:/var/lib/postgresql/data:Z"
    environment:
      POSTGRES_USER: awx
      POSTGRES_PASSWORD: password
      POSTGRES_DB: postgres
      http_proxy:
      https_proxy:
      no_proxy:


volumes:
  supervisor-socket:
  rsyslog-socket:
  rsyslog-config:

Thank you, Ramachandra

I edited your post. Please, next time format your post according to the following guide: How to format your forum posts
In short: please, use </> button to share codes, terminal outputs, error messages or anything that can contain special characters which would be interpreted by the MarkDown filter. Use the preview feature to make sure your text is formatted as you would expect it and check your post after you have sent it so you can still fix it.

Regarding your issue, the original problem was postfix not starting in a container which ws answered by @bluepuma77. How AWX work I think is a different issue and I’m not even sure that this is the best forum to ask about that just because it is running in a container. AWX 17.1.0 is a pretty old version by the way. Is that still supported? I guess you stil use it because latest versions require Kubernetes if I remember correctly.

Generally you would need log messages to see why certain features don’t work. I checked your compose file and all I can see is a variabale that I can’t find in the documentation of AWX and not even in the sourcecode: POSTFIX_ENABLED.

Please, explain why you think it is Docker-related (besides what we already discussed about postfix and systemd) so we can focus on your real issue to help you.

You can also find some links about the Ansible community to find forums where you can ask about Ansible or AWX