Comments on How to install Mastodon Social Network with Docker on Ubuntu 18.04 LTS

Mastodon is a free, decentralized and open-source social network. It was created as an alternative to Twitter. This tutorial will teach you how to set up your instance of Mastodon on a server with Ubuntu 18.04 using Docker.

12 Comment(s)

Add comment

Please register in our forum first to comment.

Comments

By: Benet J. Darder

Also it's necessari to do the following

sudo chown -R 991:991 public/system 

in order to grant acces to Docker user into the public/system folder 

 

Regards!

By: Augusto

Creating network "mastodon_internal_network" with the default driver

Creating network "mastodon_external_network" with the default driver

Creating mastodon_db_1    ... done

Creating mastodon_redis_1 ... done

rails aborted!

PG::ConnectionBad: could not translate host name "db" to address: Name or service not known

/opt/mastodon/vendor/bundle/ruby/2.6.0/gems/pg-1.2.2/lib/pg.rb:58:in `initialize'

/opt/mastodon/vendor/bundle/ruby/2.6.0/gems/pg-1.2.2/lib/pg.rb:58:in `new'

/opt/mastodon/vendor/bundle/ruby/2.6.0/gems/pg-1.2.2/lib/pg.rb:58:in `connect'

on command " docker-compose run --rm web rails db:migrate"

By: G

You need to make sure the PG container is up. I had to add a password and a username for it in the docker-compose.yml file.

By: Robert McGovern

You you better explain that? I've followed this guide & also the https://www.linode.com/docs/applications/messaging/install-mastodon-on-ubuntu-1604/ guide, and like Augusto it starts the db and redis, and then dies

[xxx@xxx mastodon]# docker-compose run --rm web rails db:migrateStarting mastodon_redis_1 ... doneStarting mastodon_db_1    ... donerails aborted!PG::ConnectionBad: could not translate host name "db" to address: Name or service not known/opt/mastodon/vendor/bundle/ruby/2.6.0/gems/pg-1.2.3/lib/pg.rb:58:in `initialize'/opt/mastodon/vendor/bundle/ruby/2.6.0/gems/pg-1.2.3/lib/pg.rb:58:in `new'

By: John

Here is what worked for me. Edit the file docker-compose.yml to add a password for the PostgreSQL user in the db section:

    environment:

      - POSTGRES_PASSWORD=myPassword

Set the same password as you use in the variable DB_PASS in the file .env.production.

 

By: Sandro

You are straight up cloning master which is a very very very bad idea. The master branch is the development branch which tends to be unstable, can contain unfishied or totaly broken features and security bugs. Always checkout the latest released tag after cloning or download the source code from the latest release.Or just grab the pre-build docker image to skip half of this guide.

By: rakesh

on this step :

 

Insert the above key in the configuration file.

$ sed -i -e "s/SECRET_KEY_BASE=/&${SECRET_KEY_BASE}/" .env.productioni got error :root@rak:~/mastodon# sed -i -e "s/SECRET_KEY_BASE=/&${SECRET_KEY_BASE}/" .env.productionsed: -e expression #1, char 55: unknown option to `s'

By: Axel

you had a problem while creating your SECRET_KEY_BASE and ended up with something with a / in your Variable. I had the same problem and fixed it by doing it again (and verifying that SECRET_KEY_BASE was correct for running it through sed).

By: Lars

Hello,

i stuck at the connection to the Database.

It get this Error Message:

 

FATAL:  password authentication failed for user "User" (PG::ConnectionBad)

As  Variable in docker-compose.yml i have

 

environment:

      - POSTGRES_PASSWORD=superSecret      - POSTGRES_DB=mastodon_social      - POSTGRES_USER=User

The same in .env.production

DB_HOST=dbDB_USER=UserDB_NAME=mastodon_socialDB_PASS=SuperSecretDB_PORT=5432

Recompiled and still the same message

What is wrong? Can anyone help me?

 

By: someone

I ran into a few points while attempting to follow these instructions:1> I had to set a postgres user in the docker-compose.yml for the db to not be stuck in a restart loop.2> I had to enter the postgres container and create the mastodon user/password and set them to superuser.3> I had to set the db setting in the .env.production file, including changing it from a local socker to a remote port on the DB container.4> I had to set the redis setting in the .env.production file from localhost to the redis containerwhat would be the likelihood of a updtae to this article or a revamp for 20.04 docker?

By: Gem

2> I had to enter the postgres container and create the mastodon user/password and set them to superuser. 3> I had to set the db setting in the .env.production file, including changing it from a local socker to a remote port on the DB container. 4> I had to set the redis setting in the .env.production file from localhost to the redis container

Any chance you might be able to describe how to get the docker instances to communicate with each other (i.e., how to get one instance to connect to a port on the other)? I'm new to docker and any help you could provide would be appreciated. Thanks!

By: Gem

For anyone else struggling with this, I had to make the following changes to ensure that the DB could be found:

Update docker-compose.yml to add the following environment variables to `db`:

```

    - POSTGRES_DB=mastodon_production    - POSTGRES_PASSWORD=password    - POSTGRES_USER=mastodon

```

Update .env.production to change:

```REDIS_HOST=redis[...]DB_HOST=dbDB_NAME=mastodon_productionDB_PASS=password

```

And finally, I had to run `docker-compose up`, let it fail because the DB wasn't in a usable state, kill it with CTRL+C, and then run `docker-compose run --rm web rails db:migrate` before it would actually do the migrations.