Mastodon: Docker instructions no longer work

Created on 17 Feb 2018  路  7Comments  路  Source: tootsuite/mastodon

After this PR (https://github.com/tootsuite/mastodon/pull/6369) it appears the Docker instructions no longer work.

Steps to repro

  1. Set up a fresh Ubuntu Server 16.04
  2. Follow the instructions in the Docker guide
  3. Get to this step: docker-compose run --rm web rake db:migrate

Expected

It migrates the DB.

Actual

PG::ConnectionBad: could not translate host name "db" to address: Name does not resolve

After I roll back that PR, it manages to connect to Postgres but I get a new error:

PG::ConnectionBad: fe_sendauth: no password supplied

I'm not sure if the last error is related or if there's some other step I'm missing.


  • [x] I searched or browsed the repo鈥檚 other issues to ensure this is not a duplicate.
  • [ ] This bug happens on a tagged release and not on master (If you're a user, don't worry about this).
admin support

Most helpful comment

@akihikodaki thanks! docker-compose down worked and I was able to upgrade

All 7 comments

It works for me. The only difference as far as I know is that I'm on up-to-date Arch Linux. They should have different Docker versions and that can be a problem.

$ docker -v
Docker version 18.02.0-ce, build fc4de447b5

Please also make sure that you correctly merged your old configurations with the latest upstream configuration. I know a case that an administrator mistakenly removed networks section, which conflicted with volumes section edited by himself and that resulted in the same error.

Just tried updating to v2.3.0rc1 using the docker instructions and got the same error.

downgraded to v2.2.0, rebuilt, and everything works fine

it is an older docker version though. that must be the issue:

$ docker -v
Docker version 17.12.1-ce, build 7390fc6

Something odd happened... I cannot reproduce even on fresh Ubuntu 16.04. I created Ubuntu virtual machine with the following command:

virt-install --name ubuntu-server -r 2048 --vcpus 4 --nographics --disk path=ubuntu-server.qcow2,size=128,format=qcow2 --location http://ftp.tsukuba.wide.ad.jp/Linux/ubuntu/dists/xenial/main/installer-amd64/ --extra-args console=ttyS0

And I commanded to the virtual machine:

wget -O - https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo vi /etc/apt/sources.list # add stable repository
sudo apt update
sudo apt install docker-ce git python-pip
pip install docker-compose
cd /
sudo git clone https://github.com/tootsuite/mastodon.git
cd mastodon
sudo cp .env.production.sample .env.production
sudo mkdir public/assets
sudo touch public/assets/500.html public/assets/sw.js # workaround https://github.com/docker/docker-py/issues/1841
sudo systemctl start docker
sudo ~/.local/bin/docker-compose build
sudo ~/.local/bin/docker-compose run --rm web rake secret
sudo ~/.local/bin/docker-compose run --rm web rake secret
sudo vi .env.production # fill PAPERCLIP_SECRET and SECRET_KEY_BASE, using keys generated by the last two commands
sudo ~/.local/bin/docker-compose run --rm web rake db:migrate

The installed version is 17.12.1-ce:

$ docker -v
Docker version 17.12.1-ce, build 7390fc6

I have no clue to resolve the problem now.

@akihikodaki the docker file has db persistence off by default I think. I wonder if that makes a difference. or maybe it is only caused on upgrades and not fresh installs?

I will try to experiment later tonight and try to get reproduction steps

@akihikodaki I also had no issue if I created a new vm and build master immediately.

I did reproduce it by first checking out v2.2.0, building that, then trying to build v2.3.0rc1

part 1: this all works as expected

wget -O - https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo vi /etc/apt/sources.list # add stable repository
sudo apt update
sudo apt install docker-ce git python-pip
pip install docker-compose
cd /
sudo git clone https://github.com/tootsuite/mastodon.git
cd mastodon

###################
# This bit differs from steps you listed above
git checkout v2.2.0
sudo vi docker-compose.yml # un-comment the database persistence bit
###################

sudo cp .env.production.sample .env.production
sudo mkdir public/assets
sudo touch public/assets/500.html public/assets/sw.js # workaround https://github.com/docker/docker-py/issues/1841
sudo systemctl start docker
sudo ~/.local/bin/docker-compose build
sudo ~/.local/bin/docker-compose run --rm web rake secret
sudo ~/.local/bin/docker-compose run --rm web rake secret
sudo vi .env.production # fill PAPERCLIP_SECRET and SECRET_KEY_BASE, using keys generated by the last two commands
sudo ~/.local/bin/docker-compose run --rm web rake db:migrate

part 2: this blows up

git stash 
git checkout v2.3.0rc1
git stash pop 
sudo vi docker-compose.yml # resolve merge errors
sudo ~/.local/bin/docker-compose build
sudo ~/.local/bin/docker-compose run --rm web rake db:migrate

@astronaut-wannabe Thanks for your report.

I confirmed that:

  1. docker-compose run --rm does not remove dependency containers, including db.
  2. Docker uses an old container even if networks property is changed since it was built.

The combination of the two behavior caused the problem. A suggested solution is to run the following command before executing docker-compose run:

docker-compose down

This removes the old container, and Docker will create a new one when you run docker-compose run next.

@Gargron Please note this when you write the release description for v2.3.0.

@akihikodaki thanks! docker-compose down worked and I was able to upgrade

Was this page helpful?
0 / 5 - 0 ratings