Running Docker image on CentOS v8 + Podman: initialization?

I’m trying to get the Docker image up and running on my CentOS v8.3. server, using Podman.
Running appears to be fine now, all the servers up, had to make some adjustments to get the environment variables in there (podman-compose seems to have issues using the .env files).
But the servers are not initialising themselves, so plenty of errors in the logs on that.
The main issue that I have:

  • How can I have the container initialize the servers in there?

  • this guide here tells me I should run docker-compose run --rm web bundle exec rake mastodon:setup to have the container initialise itself and spit out a configuration. But I get error messages for the database and redis when I try to feed my setting to the script:

    PostgreSQL host: localhost
    PostgreSQL port: 5432
    Name of PostgreSQL database: mastodon_production
    Name of PostgreSQL user: mastodon
    Password of PostgreSQL user: ***********
    Database connection could not be established with this configuration, try again.
    could not connect to server: Connection refused
    Is the server running on host “localhost” (::1) and accepting
    TCP/IP connections on port 5432?
    could not connect to server: Connection refused
    Is the server running on host “localhost” (127.0.0.1) and accepting
    TCP/IP connections on port 5432?

Apparently the script is asking for credentials to an existing/running server?
And a similar things happens for Redis.

Other install guides that I found are:

Any pointers would be great, as I’m mostly guessing now.

Many thanks!

What are your REDIS_HOST or DATABASE_HOST settings? They shouldn’t be localhost with containers

Here’s what I do:

In .env.production (file attached):

  • outcomment ElasticSearch and AWS
  • LOCAL_DOMAIN=mastodon.offerman.com
  • REDIS_HOST=mastodon_redis_1
  • DB_HOST=mastodon_db_1

In docker-compose.yml (file attached):

db:
    healthcheck:
        test: ["CMD", "pg_isready", "-U", "mastodon", "-d", "mastodon_production"]

(borrowed these adjustments from here)

Then I run the command that is suppose to do the initialization and give back the configuration, including some secret variables (if I’m not mistaken):

podman-compose run --rm web bundle exec rake mastodon:setup

Then this happens:

using podman version: podman version 2.2.1
podman pod create --name=mastodon --share net -p 127.0.0.1:4000:4000 -p 127.0.0.1:3000:3000
bcc583c8c9f3729226ada597342ee9cc6dd1684f45c5f903b9dbc93bbc480dab
0
Namespace(T=False, cnt_command=['bundle', 'exec', 'rake', 'mastodon:setup'], command='run', detach=False, dry_run=False, e=None, entrypoint=None, file=['docker-compose.yml'], label=None, name=None, no_ansi=False, no_cleanup=False, no_deps=False, podman_path='podman', project_name=None, publish=None, rm=True, service='web', service_ports=False, transform_policy='1podfw', user=None, volume=None, workdir=None)
podman run --rm -i --name=mastodon_web_tmp37432 --pod=mastodon --label io.podman.compose.config-hash=123 --label io.podman.compose.project=mastodon --label io.podman.compose.version=0.0.1 --label com.docker.compose.container-number=1 --label com.docker.compose.service=web --env-file /home/oc-mastodon/podman-mastodon.offerman.com/mastodon/.env.production -v /home/oc-mastodon/podman-mastodon.offerman.com/mastodon/./docker-volume/public/system:/mastodon/public/system --add-host db:127.0.0.1 --add-host mastodon_db_1:127.0.0.1 --add-host redis:127.0.0.1 --add-host mastodon_redis_1:127.0.0.1 --add-host web:127.0.0.1 --add-host mastodon_web_1:127.0.0.1 --add-host streaming:127.0.0.1 --add-host mastodon_streaming_1:127.0.0.1 --add-host sidekiq:127.0.0.1 --add-host mastodon_sidekiq_1:127.0.0.1 --tty --healthcheck-command /bin/sh -c 'wget -q --spider --proxy=off localhost:3000/health || exit 1' tootsuite/mastodon bundle exec rake mastodon:setup
Your instance is identified by its domain name. Changing it afterward will break things.
Domain name: mastodon.offerman.com
Single user mode disables registrations and redirects the landing page to your public profile.
Do you want to enable single user mode? No
Are you using Docker to run Mastodon? Yes
PostgreSQL host: mastodon_db_1
PostgreSQL port: 5432
Name of PostgreSQL database: mastodon_production
Name of PostgreSQL user: mastodon
Password of PostgreSQL user: ******
Database connection could not be established with this configuration, try again.
could not connect to server: Connection refused
    Is the server running on host "mastodon_db_1" (127.0.0.1) and accepting
    TCP/IP connections on port 5432?
Try again? Yes
PostgreSQL host: db
PostgreSQL port: 5432
Name of PostgreSQL database: postgres
Name of PostgreSQL user: postgres
Password of PostgreSQL user: ******
Database connection could not be established with this configuration, try again.
could not connect to server: Connection refused
    Is the server running on host "db" (127.0.0.1) and accepting
    TCP/IP connections on port 5432?

No matter what I try, I always get the same error message.
And a similar thing happens when I skip the Postgres step and move on to the Redis configuration.
It appears to me that this command just generates an .env-production file, but the configuration of the services is not happening.
Am I missing something/a step here?

For what it’s worth: if I simply start up the whole container using the current configuration:

podman-compose up -d

all the services come up.
But of course when I check the logs, there are many errors about databases/services not being configured.

So again: think I’m missing a step here?

.env.production:

# This is a sample configuration file. You can generate your configuration
# with the `rake mastodon:setup` interactive setup wizard, but to customize
# your setup even further, you'll need to edit it manually. This sample does
# not demonstrate all available configuration options. Please look at
# https://docs.joinmastodon.org/admin/config/ for the full documentation.    

# Federation
# ----------
# This identifies your server and cannot be changed safely later
# ----------
LOCAL_DOMAIN=mastodon.offerman.com

# Redis
# -----
REDIS_HOST=mastodon_redis_1
REDIS_PORT=6379

# PostgreSQL
# ----------
DB_HOST=mastodon_db_1
DB_USER=mastodon
DB_NAME=mastodon_production
DB_PASS=
DB_PORT=5432

# ElasticSearch (optional)
# ------------------------
#ES_ENABLED=true
#ES_HOST=localhost
#ES_PORT=9200

# Secrets
# -------
# Make sure to use `rake secret` to generate secrets
# -------
SECRET_KEY_BASE=
OTP_SECRET=

# Web Push
# --------
# Generate with `rake mastodon:webpush:generate_vapid_key`
# --------
VAPID_PRIVATE_KEY=
VAPID_PUBLIC_KEY=

# Sending mail
# ------------
SMTP_SERVER=smtp.mailgun.org
SMTP_PORT=587
SMTP_LOGIN=
SMTP_PASSWORD=
SMTP_FROM_ADDRESS=notificatons@example.com

# File storage (optional)
# -----------------------
#S3_ENABLED=true
#S3_BUCKET=files.example.com
#AWS_ACCESS_KEY_ID=
#AWS_SECRET_ACCESS_KEY=
#S3_ALIAS_HOST=files.example.com

docker-compose.yml:

version: '3'
services:

  db:
    restart: always
    image: postgres:9.6-alpine
    shm_size: 256mb
    networks:
      - internal_network
    healthcheck:
      test: ["CMD", "pg_isready", "-U", "mastodon", "-d", "mastodon_production"]
    volumes:
      - ./docker-volume/postgres:/var/lib/postgresql/data

  redis:
    restart: always
    image: redis:6.0-alpine
    networks:
      - internal_network
    healthcheck:
      test: ["CMD", "redis-cli", "ping"]
    volumes:
      - ./docker-volume/redis:/data

#  es:
#    restart: always
#    image: docker.elastic.co/elasticsearch/elasticsearch-oss:6.8.10
#    environment:
#      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
#      - "cluster.name=es-mastodon"
#      - "discovery.type=single-node"
#      - "bootstrap.memory_lock=true"
#    networks:
#      - internal_network
#    healthcheck:
#      test: ["CMD-SHELL", "curl --silent --fail localhost:9200/_cluster/health || exit 1"]
#    volumes:
#      - ./docker-volume/elasticsearch:/usr/share/elasticsearch/data
#    ulimits:
#      memlock:
#        soft: -1
#        hard: -1

  web:
    build: .
    image: tootsuite/mastodon
    #restart: always
    env_file: .env.production
    command: bash -c "rm -f /mastodon/tmp/pids/server.pid; bundle exec rails s -p 3000"
    networks:
      - external_network
      - internal_network
    healthcheck:
      test: ["CMD-SHELL", "wget -q --spider --proxy=off localhost:3000/health || exit 1"]
    ports:
      - "127.0.0.1:3000:3000"
    depends_on:
      - db
      - redis
#      - es
    volumes:
      - ./docker-volume/public/system:/mastodon/public/system

  streaming:
    build: .
    image: tootsuite/mastodon
    restart: always
    env_file: .env.production
    command: node ./streaming
    networks:
      - external_network
      - internal_network
    healthcheck:
      test: ["CMD-SHELL", "wget -q --spider --proxy=off localhost:4000/api/v1/streaming/health || exit 1"]
    ports:
      - "127.0.0.1:4000:4000"
    depends_on:
      - db
      - redis

  sidekiq:
    build: .
    image: tootsuite/mastodon
    restart: always
    env_file: .env.production
    command: bundle exec sidekiq
    depends_on:
      - db
      - redis
    networks:
      - external_network
      - internal_network
    volumes:
      - ./docker-volume/public/system:/mastodon/public/system
## Uncomment to enable federation with tor instances along with adding the following ENV variables
## http_proxy=http://privoxy:8118
## ALLOW_ACCESS_TO_HIDDEN_SERVICE=true
#  tor:
#    image: sirboops/tor
#    networks:
#      - external_network
#      - internal_network
#
#  privoxy:
#    image: sirboops/privoxy
#    volumes:
#      - ./docker-volume/priv-config:/opt/config
#    networks:
#      - external_network
#      - internal_network

networks:
  external_network:
  internal_network:
    internal: true

can you exec into your postgres container and see if it is running? anything in podman-compose logs postgres ?

The init command/script podman-compose run --rm web bundle exec rake mastodon:setup does not start anything else, only creates a pod:

podman pod create --name=mastodon --share net -p 127.0.0.1:3000:3000 -p 127.0.0.1:4000:4000

and then creates the web instance that runs the config script:

podman run --rm -i --name=mastodon_web_tmp29350 --pod=mastodon --label io.podman.compose.config-hash=123 --label io.podman.compose.project=mastodon --label io.podman.compose.version=0.0.1 --label com.docker.compose.container-number=1 --label com.docker.compose.service=web --env-file /home/oc-mastodon/podman-mastodon.offerman.com/mastodon/.env.production -v /home/oc-mastodon/podman-mastodon.offerman.com/mastodon/./docker-volume/public/system:/mastodon/public/system --add-host db:127.0.0.1 --add-host mastodon_db_1:127.0.0.1 --add-host redis:127.0.0.1 --add-host mastodon_redis_1:127.0.0.1 --add-host web:127.0.0.1 --add-host mastodon_web_1:127.0.0.1 --add-host streaming:127.0.0.1 --add-host mastodon_streaming_1:127.0.0.1 --add-host sidekiq:127.0.0.1 --add-host mastodon_sidekiq_1:127.0.0.1 --tty --healthcheck-command /bin/sh -c 'wget -q --spider --proxy=off localhost:3000/health || exit 1' tootsuite/mastodon bundle exec rake mastodon:setup

Nothing else is started. But just before the web instance is started, I see this:

Namespace(T=False, cnt_command=['bundle', 'exec', 'rake', 'mastodon:setup'], command='run', detach=False, dry_run=False, e=None, entrypoint=None, file=['docker-compose.yml'], label=None, name=None, no_ansi=False, no_cleanup=False, no_deps=False, podman_path='podman', project_name=None, publish=None, rm=True, service='web', service_ports=False, transform_policy='1podfw', user=None, volume=None, workdir=None)

Which I’ve never seen before.

After the script has finished, the web instance shuts down, and the only thing left running is the empty pod. I don’t see any sign of any other container being started.
And the script at the end (where it tries to initialize the database) complains about not being able to find the database:

Now that configuration is saved, the database schema must be loaded.
If the database already exists, this will erase its contents.
Prepare the database now? Yes
Running `RAILS_ENV=production rails db:setup` ...

could not connect to server: Connection refused
    Is the server running on host "mastodon_db_1" (127.0.0.1) and accepting
    TCP/IP connections on port 5432?
Couldn't create 'mastodon_production' database. Please check your configuration.
rails aborted!
ActiveRecord::ConnectionNotEstablished: could not connect to server: Connection refused
    Is the server running on host "mastodon_db_1" (127.0.0.1) and accepting
    TCP/IP connections on port 5432?

As far as I can see other containers are never started, and no logs are available.

If I start the normal pod using podman-compose up -d all the containers are started by podman:

using podman version: podman version 2.2.1
podman pod create --name=mastodon --share net -p 127.0.0.1:4000:4000 -p 127.0.0.1:3000:3000
f8cfa3cea753fea5ca94212e3a7ecd729a1ecffdd1d63d435abfb7d2206c5009
0
podman run --name=mastodon_db_1 -d --pod=mastodon --label io.podman.compose.config-hash=123 --label io.podman.compose.project=mastodon --label io.podman.compose.version=0.0.1 --label com.docker.compose.container-number=1 --label com.docker.compose.service=db -v /home/oc-mastodon/podman-mastodon.offerman.com/mastodon/./docker-volume/postgres:/var/lib/postgresql/data --add-host db:127.0.0.1 --add-host mastodon_db_1:127.0.0.1 --add-host redis:127.0.0.1 --add-host mastodon_redis_1:127.0.0.1 --add-host web:127.0.0.1 --add-host mastodon_web_1:127.0.0.1 --add-host streaming:127.0.0.1 --add-host mastodon_streaming_1:127.0.0.1 --add-host sidekiq:127.0.0.1 --add-host mastodon_sidekiq_1:127.0.0.1 --shm-size 256mb --restart always --healthcheck-command /bin/sh -c pg_isready' '-U' 'mastodon' '-d' 'mastodon_production postgres:9.6-alpine
ab7d6c11e9163306f457fb7d374802d2c8a26114846132ca831327164ee6e26b
0
podman run --name=mastodon_redis_1 -d --pod=mastodon --label io.podman.compose.config-hash=123 --label io.podman.compose.project=mastodon --label io.podman.compose.version=0.0.1 --label com.docker.compose.container-number=1 --label com.docker.compose.service=redis -v /home/oc-mastodon/podman-mastodon.offerman.com/mastodon/./docker-volume/redis:/data --add-host db:127.0.0.1 --add-host mastodon_db_1:127.0.0.1 --add-host redis:127.0.0.1 --add-host mastodon_redis_1:127.0.0.1 --add-host web:127.0.0.1 --add-host mastodon_web_1:127.0.0.1 --add-host streaming:127.0.0.1 --add-host mastodon_streaming_1:127.0.0.1 --add-host sidekiq:127.0.0.1 --add-host mastodon_sidekiq_1:127.0.0.1 --restart always --healthcheck-command /bin/sh -c redis-cli' 'ping redis:6.0-alpine
4f152fc093f43710650be1f9c5bd75847404444f90e9ec81caafc3688961268e
0
podman run --name=mastodon_web_1 -d --pod=mastodon --label io.podman.compose.config-hash=123 --label io.podman.compose.project=mastodon --label io.podman.compose.version=0.0.1 --label com.docker.compose.container-number=1 --label com.docker.compose.service=web --env-file /home/oc-mastodon/podman-mastodon.offerman.com/mastodon/.env.production -v /home/oc-mastodon/podman-mastodon.offerman.com/mastodon/./docker-volume/public/system:/mastodon/public/system --add-host db:127.0.0.1 --add-host mastodon_db_1:127.0.0.1 --add-host redis:127.0.0.1 --add-host mastodon_redis_1:127.0.0.1 --add-host web:127.0.0.1 --add-host mastodon_web_1:127.0.0.1 --add-host streaming:127.0.0.1 --add-host mastodon_streaming_1:127.0.0.1 --add-host sidekiq:127.0.0.1 --add-host mastodon_sidekiq_1:127.0.0.1 --healthcheck-command /bin/sh -c 'wget -q --spider --proxy=off localhost:3000/health || exit 1' tootsuite/mastodon bash -c rm -f /mastodon/tmp/pids/server.pid; bundle exec rails s -p 3000
3ec5ab234b27a2d40192a0965bdfc7568796d375fa43639068e1c5b12aacbaae
0
podman run --name=mastodon_streaming_1 -d --pod=mastodon --label io.podman.compose.config-hash=123 --label io.podman.compose.project=mastodon --label io.podman.compose.version=0.0.1 --label com.docker.compose.container-number=1 --label com.docker.compose.service=streaming --env-file /home/oc-mastodon/podman-mastodon.offerman.com/mastodon/.env.production --add-host db:127.0.0.1 --add-host mastodon_db_1:127.0.0.1 --add-host redis:127.0.0.1 --add-host mastodon_redis_1:127.0.0.1 --add-host web:127.0.0.1 --add-host mastodon_web_1:127.0.0.1 --add-host streaming:127.0.0.1 --add-host mastodon_streaming_1:127.0.0.1 --add-host sidekiq:127.0.0.1 --add-host mastodon_sidekiq_1:127.0.0.1 --restart always --healthcheck-command /bin/sh -c 'wget -q --spider --proxy=off localhost:4000/api/v1/streaming/health || exit 1' tootsuite/mastodon node ./streaming
3dbbd33eecc6bf84fb836a12405f307ee3ebb102398f60f98be267bb9f2dad7a
0
podman run --name=mastodon_sidekiq_1 -d --pod=mastodon --label io.podman.compose.config-hash=123 --label io.podman.compose.project=mastodon --label io.podman.compose.version=0.0.1 --label com.docker.compose.container-number=1 --label com.docker.compose.service=sidekiq --env-file /home/oc-mastodon/podman-mastodon.offerman.com/mastodon/.env.production -v /home/oc-mastodon/podman-mastodon.offerman.com/mastodon/./docker-volume/public/system:/mastodon/public/system --add-host db:127.0.0.1 --add-host mastodon_db_1:127.0.0.1 --add-host redis:127.0.0.1 --add-host mastodon_redis_1:127.0.0.1 --add-host web:127.0.0.1 --add-host mastodon_web_1:127.0.0.1 --add-host streaming:127.0.0.1 --add-host mastodon_streaming_1:127.0.0.1 --add-host sidekiq:127.0.0.1 --add-host mastodon_sidekiq_1:127.0.0.1 --restart always tootsuite/mastodon bundle exec sidekiq
2862d0193f4aab7466bb1a1acf8cf09ce449e040f29ce7854b530536bfa79a24
0

Of course, if I now check the logs of these containers, I see many errors about the databases not being initialised.
So, appears to be something amiss with the init configuration starting only the init web instance.

podman-compose is docker-compose’s poor brother - although I use podman a lot personally and professionally I have encountered quite a lot of small incompatibilities. Looks like podman-compose run behaves as it had --no-deps specified. What I’d try is to create pod by hand with the commands you have seen already, then starting db container and finally running the rake command with podman-compose run.

This is pretty hopeless, but I managed to reproduce your problem and somehow work it around by adding

   environment:
      - "POSTGRES_PASSWORD=xxxxxxxx"

to the db service in docker-compose.yml and then starting postgres by running

  podman-compose run db -d

Didn’t manage to bring redis up the same way

 podman-compose run redis -d

but this was because of some funny permission issues (I am running rootless):

find: .: Permission denied
chown: .: Permission denied

at least with this setup

podman-compose run  web bundle exec rake mastodon:setup

can connect to the database if the password is the same as entered in the docker-compose.yml file.
Then it breaks with redis, for the reasons stated above.

(This is podman 3.1.2 on Fedora, CentOS 8 has probably older one).

Thanks saper, for you efforts!
Your hint on the POSTGRES_PASSWORD env var was the last key to get through the initialization successfully.
Run into a new (unrelated) problem, but first what I did to get here:

Set these env var values:

-e LOCAL_DOMAIN=mastodon.example.com \
-e REDIS_HOST=mastodon_redis_1 \
-e REDIS_PORT=6379 \
-e DB_HOST=mastodon_db_1 \
-e DB_USER=mastodon \
-e DB_NAME=mastodon_production \
-e DB_PASS=************ \
-e DB_PORT=5432 \
-e SECRET_KEY_BASE \
-e OTP_SECRET \
-e VAPID_PRIVATE_KEY \
-e VAPID_PUBLIC_KEY \
-e SMTP_SERVER=mail.example.com \
-e SMTP_PORT=587 \
-e SMTP_LOGIN=mail-user \
-e SMTP_PASSWORD=************ \
-e SMTP_FROM_ADDRESS=noreply@example.com \
-e RAILS_ENV=development \
-e NODE_ENV=development \
-e POSTGRES_PASSWORD=************ \
-e POSTGRES_USER=mastodon \

Note that I stopped using the .env.production file, and instead added everything to the command line.
I also stopped using the podman-compose command, and instead created the pod and containers by hand. For the initialization I started the pod, and Postgres and Redis like this:

podman pod create --name=mastodon --share net -p 127.0.0.1:4000:4000 -p 127.0.0.1:3000:3000

podman run --name=mastodon_db_1 -d --pod=mastodon --label io.podman.compose.config-hash=123 --label io.podman.compose.project=mastodon --label io.podman.compose.version=0.0.1 --label com.docker.compose.container-number=1 --label com.docker.compose.service=db -v /home/oc-mastodon/podman-mastodon.example.com/mastodon/./docker-volume/postgres:/var/lib/postgresql/data \
-e LOCAL_DOMAIN=mastodon.example.com \
-e REDIS_HOST=mastodon_redis_1 \
-e REDIS_PORT=6379 \
-e DB_HOST=mastodon_db_1 \
-e DB_USER=mastodon \
-e DB_NAME=mastodon_production \
-e DB_PASS=************ \
-e DB_PORT=5432 \
-e SECRET_KEY_BASE \
-e OTP_SECRET \
-e VAPID_PRIVATE_KEY \
-e VAPID_PUBLIC_KEY \
-e SMTP_SERVER=mail.example.com \
-e SMTP_PORT=587 \
-e SMTP_LOGIN=mail-user \
-e SMTP_PASSWORD=************ \
-e SMTP_FROM_ADDRESS=noreply@example.com \
-e RAILS_ENV=development \
-e NODE_ENV=development \
-e POSTGRES_PASSWORD=************ \
-e POSTGRES_USER=mastodon \
--add-host db:127.0.0.1 --add-host mastodon_db_1:127.0.0.1 --add-host redis:127.0.0.1 --add-host mastodon_redis_1:127.0.0.1 --add-host web:127.0.0.1 --add-host mastodon_web_1:127.0.0.1 --add-host streaming:127.0.0.1 --add-host mastodon_streaming_1:127.0.0.1 --add-host sidekiq:127.0.0.1 --add-host mastodon_sidekiq_1:127.0.0.1 --shm-size 256mb --restart always --healthcheck-command '/bin/sh -c pg_isready -U mastodon -d mastodon_production' postgres:9.6-alpine

podman run --name=mastodon_redis_1 -d --pod=mastodon --label io.podman.compose.config-hash=123 --label io.podman.compose.project=mastodon --label io.podman.compose.version=0.0.1 --label com.docker.compose.container-number=1 --label com.docker.compose.service=redis -v /home/oc-mastodon/podman-mastodon.example.com/mastodon/./docker-volume/redis:/data \
-e LOCAL_DOMAIN=mastodon.example.com \
-e REDIS_HOST=mastodon_redis_1 \
-e REDIS_PORT=6379 \
-e DB_HOST=mastodon_db_1 \
-e DB_USER=mastodon \
-e DB_NAME=mastodon_production \
-e DB_PASS=************ \
-e DB_PORT=5432 \
-e SECRET_KEY_BASE \
-e OTP_SECRET \
-e VAPID_PRIVATE_KEY \
-e VAPID_PUBLIC_KEY \
-e SMTP_SERVER=mail.example.com \
-e SMTP_PORT=587 \
-e SMTP_LOGIN=oc-mastodon \
-e SMTP_PASSWORD=************ \
-e SMTP_FROM_ADDRESS=noreply@example.com \
-e RAILS_ENV=development \
-e NODE_ENV=development \
-e POSTGRES_PASSWORD=************ \
-e POSTGRES_USER=mastodon \
--add-host db:127.0.0.1 --add-host mastodon_db_1:127.0.0.1 --add-host redis:127.0.0.1 --add-host mastodon_redis_1:127.0.0.1 --add-host web:127.0.0.1 --add-host mastodon_web_1:127.0.0.1 --add-host streaming:127.0.0.1 --add-host mastodon_streaming_1:127.0.0.1 --add-host sidekiq:127.0.0.1 --add-host mastodon_sidekiq_1:127.0.0.1 --restart always --healthcheck-command '/bin/sh -c redis-cli ping' redis:6.0-alpine

Everything starts fine. And running the initialization is no longer a problem:

podman-compose run --rm web bundle exec rake mastodon:setup

I then add the four keys and two new SMTP options to the command lines, and restart pod/Postgres/Redis

-e SECRET_KEY_BASE=******************************************* \
-e OTP_SECRET=************************************************ \
-e VAPID_PRIVATE_KEY=***************************************************************** \
-e VAPID_PUBLIC_KEY=*************************************************************** \
-e SMTP_SERVER=mail.example.com \
-e SMTP_PORT=587 \
-e SMTP_LOGIN=mail-user \
-e SMTP_PASSWORD=************ \
-e SMTP_AUTH_METHOD=plain \
-e SMTP_OPENSSL_VERIFY_MODE=none \

All fine so far.

But when I start the web container, I get this error:

bash: bundle: command not found...
Install package 'rubygem-bundler' to provide command 'bundle'? [N/y] y
 * Waiting in queue... 
 * Loading list of packages....
The following packages have to be installed:
 rubygem-bundler-1.16.1-3.module_el8.3.0+571+bab7c6bc.noarch
     Library and utilities to manage a Ruby application's gem dependencies
Proceed with changes? [N/y] y
 * Waiting in queue...
 * Waiting for authentication...
 * Waiting in queue...
 * Downloading packages...
 * Requesting data...
 * Testing changes...
 * Installing packages...
bundler: command not found: rails
Install missing gem executables with `bundle install`

And thereafter always:

bundler: command not found: rails
Install missing gem executables with `bundle install`

I also tried running the web container with the ‘bundle install’ command, like this:

podman run --name=mastodon_web_1 -d --pod=mastodon --label io.podman.compose.config-hash=123 --label io.podman.compose.project=mastodon --label io.podman.compose.version=0.0.1 --label com.docker.compose.container-number=1 --label com.docker.compose.service=web --env-file /home/oc-mastodon/podman-mastodon.example.com/mastodon/.env.production -v /home/oc-mastodon/podman-mastodon.example.com/mastodon/./docker-volume/public/system:/mastodon/public/system \
-e LOCAL_DOMAIN=mastodon.example.com \
-e REDIS_HOST=mastodon_redis_1 \
-e REDIS_PORT=6379 \
-e DB_HOST=mastodon_db_1 \
-e DB_USER=mastodon \
-e DB_NAME=mastodon_production \
-e DB_PASS=************ \
-e DB_PORT=5432 \
-e SECRET_KEY_BASE=************************************ \
-e OTP_SECRET=******************************************************* \
-e VAPID_PRIVATE_KEY=************************************** \
-e VAPID_PUBLIC_KEY=******************************************** \
-e SMTP_SERVER=mail.example.com \
-e SMTP_PORT=587 \
-e SMTP_LOGIN=mail-user \
-e SMTP_PASSWORD=************ \
-e SMTP_AUTH_METHOD=plain \
-e SMTP_OPENSSL_VERIFY_MODE=none \
-e SMTP_FROM_ADDRESS=noreply@example.com \
-e RAILS_ENV=development \
-e NODE_ENV=development \
-e POSTGRES_PASSWORD=************ \
-e POSTGRES_USER=mastodon \
--add-host db:127.0.0.1 --add-host mastodon_db_1:127.0.0.1 --add-host redis:127.0.0.1 --add-host mastodon_redis_1:127.0.0.1 --add-host web:127.0.0.1 --add-host mastodon_web_1:127.0.0.1 --add-host streaming:127.0.0.1 --add-host mastodon_streaming_1:127.0.0.1 --add-host sidekiq:127.0.0.1 --add-host mastodon_sidekiq_1:127.0.0.1 --healthcheck-command '/bin/sh -c wget -q --spider --proxy=off localhost:3000/health || exit 1' tootsuite/mastodon bash -c rm -f /mastodon/tmp/pids/server.pid; bundle install

But that gives me a cld version problem:

Fetching gem metadata from https://rubygems.org/.........
Fetching gem metadata from https://rubygems.org/.
Resolving dependencies......
cld3-3.4.2 requires ruby version < 3.1.0, >= 2.6.0, which is incompatible with the current version, ruby 2.5.5p157

Closer… but not there yet %-)

So you gave up on podman-compose only for initialization?

Can you be more specific which command are you using for that? podman or podman-compose?

This might be important because you might be losing the volume that should be attached to the web container.

How do you deal with rake mastodon:setup writing the configuration file?

Since you need .env.production anyway, I wouldn’t bother stuffing all the information into the environment variables; probably keeping just POSTGRES_PASSWORD in the compose config file should be enough to get the db initialized.