# Issue regarding Docker development image

**URL:** https://meta.discourse.org/t/issue-regarding-docker-development-image/53702
**Category:** Development
**Created:** [December 2, 2016, 5:47pm UTC](https://meta.discourse.org/t/issue-regarding-docker-development-image/53702 "2016-12-02T17:47:12Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![zuzust](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zuzust/32/120850_2.png) [@zuzust](https://meta.discourse.org/u/zuzust)
#### Post date: [December 2, 2016, 5:47pm UTC](https://meta.discourse.org/t/issue-regarding-docker-development-image/53702/1 "2016-12-02T17:47:13Z")

</div>

I’ve tried to setup my Discourse development environment the Docker way, but I’ve realized that `boot_env` script tries to pull a non existent `discourse/discourse_dev:latest` docker image. Instead, a `discourse/dev:latest` image exists in Docker Hub, but it is outdated (version 1.0.13).

So I’ve tried to build it myself running

`$ sudo ruby build.rb -i discourse_dev`

But when I run

`$ ./bin/docker/boot_env --init`

I get an error message regarding PostgreSQL:

```bash
Migrating database...
URGENT: could not connect to server: No such file or directory
	Is the server running locally and accepting
	connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
 Failed to initialize site default
URGENT: could not connect to server: No such file or directory
	Is the server running locally and accepting
	connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
 Failed to initialize site default
rake aborted!
PG::ConnectionBad: could not connect to server: No such file or directory
	Is the server running locally and accepting
	connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

```

Any ideas to fix it?

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [December 2, 2016, 6:50pm UTC](https://meta.discourse.org/t/issue-regarding-docker-development-image/53702/2 "2016-12-02T18:50:58Z")

</div>

> [@zuzust](#):
>
> So I’ve tried to build it myself running
> 
> $ sudo ruby build.rb -i discourse\_dev

So the image build successfully for you, good to know.

Let me take a look at this.

---

<div class="post-metadata">

### Author: ![ibnesayeed](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ibnesayeed/32/120427_2.png) [@ibnesayeed](https://meta.discourse.org/u/ibnesayeed)
#### Post date: [December 5, 2016, 12:07am UTC](https://meta.discourse.org/t/issue-regarding-docker-development-image/53702/3 "2016-12-05T00:07:24Z")

</div>

> [@zuzust](#):
>
> I’ve tried to setup my Discourse development environment the Docker way, but I’ve realized that boot\_env script tries to pull a non existent discourse/discourse\_dev:latest docker image. Instead, a discourse/dev:latest image exists in Docker Hub, but it is outdated (version 1.0.13).

I too am interested in an official well maintained docker image for development where I can simply mount my working directory and map a port then land into the bash prompt of the container. It should ship with some setup scripts to make the engines cracking inside.

Additionally, it would be good to have a developer documentation maintained similar to the one at:  
[https://github.com/discourse/discourse/blob/master/docs/DEVELOPER-ADVANCED.md](https://github.com/discourse/discourse/blob/master/docs/DEVELOPER-ADVANCED.md)

---

<div class="post-metadata">

### Author: ![ibnesayeed](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ibnesayeed/32/120427_2.png) [@ibnesayeed](https://meta.discourse.org/u/ibnesayeed)
#### Post date: [December 5, 2016, 4:13am UTC](https://meta.discourse.org/t/issue-regarding-docker-development-image/53702/4 "2016-12-05T04:13:37Z")

</div>

I tried the following the [Developing using Docker](https://github.com/discourse/discourse/tree/master/bin/docker) guide:

```plaintext
$ cd /tmp
$ git clone https://github.com/discourse/discourse.git
$ cd discourse
$ ./bin/docker/boot_dev --init

```

Realized that it is looking for `discourse/discourse_dev:latest` image which doesn’t exist in the DockerHub repository. So I decided to build it locally and tag accordingly:

```plaintext
$ cd /tmp
$ git clone https://github.com/discourse/discourse_docker.git
$ cd discourse_docker
$ docker build -t discourse/discourse_dev image/discourse_dev

```

It complained about missing template files and failed to build. So I looked at the corresponding Dockerfile to find out what files are being added then I copied them from the template directory:

```plaintext
$ cp templates/redis.template.yml templates/postgres.template.yml image/discourse_dev
$ docker build -t discourse/discourse_dev image/discourse_dev

```

Voila! Success! 🙂

Going back to the main discourse directory to setup the work environment:

```plaintext
$ cd /tmp/discourse
$ ./bin/docker/boot_dev --init

```

Container spun and gems bundled, but database migration failed:

```plaintext
Bundle complete! 98 Gemfile dependencies, 184 gems now installed.
Use `bundle show [gemname]` to see where a bundled gem is installed.
Post-install message from certified:
IMPORTANT: Remember to use the included executable `certifed-update` regularly to keep your certificate bundle up to date.
Migrating database...
Rails Error: Unable to access log file. Please ensure that /src/log/development.log exists and is writable (ie, make it writable for user and group: chmod 0664 /src/log/development.log). The log level has been raised to WARN and the output directed to STDERR until the problem is fixed.
rake aborted!
Errno::EACCES: Permission denied @ rb_sysopen - /src/tmp/ember-rails/ember.js
/src/config/environment.rb:5:in `<top (required)>'
Tasks: TOP => db:migrate => environment
(See full trace by running task with --trace)
Creating admin user...
Rails Error: Unable to access log file. Please ensure that /src/log/development.log exists and is writable (ie, make it writable for user and group: chmod 0664 /src/log/development.log). The log level has been raised to WARN and the output directed to STDERR until the problem is fixed.
rake aborted!
Errno::EACCES: Permission denied @ rb_sysopen - /src/tmp/ember-rails/ember.js
/src/config/environment.rb:5:in `<top (required)>'
Tasks: TOP => admin:create => environment
(See full trace by running task with --trace)

```

So, I decided to dive inside the running container and run the migrations manually:

```plaintext
$ docker exec -it discourse_dev bash
# cd src
# rake db:migrate

```

But the migrations did not succeed.

```plaintext
URGENT: could not connect to server: No such file or directory
	Is the server running locally and accepting
	connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
 Failed to initialize site default
URGENT: could not connect to server: No such file or directory
	Is the server running locally and accepting
	connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
 Failed to initialize site default
rake aborted!
PG::ConnectionBad: could not connect to server: No such file or directory
	Is the server running locally and accepting
	connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

Tasks: TOP => db:migrate
(See full trace by running task with --trace)

```

From here I am not sure what else should I try.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [December 5, 2016, 5:24am UTC](https://meta.discourse.org/t/issue-regarding-docker-development-image/53702/5 "2016-12-05T05:24:56Z")

</div>

@Falco can you play around with the dev image and see if you can get it going, maybe document it a bit better?

---

<div class="post-metadata">

### Author: ![ibnesayeed](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ibnesayeed/32/120427_2.png) [@ibnesayeed](https://meta.discourse.org/u/ibnesayeed)
#### Post date: [December 8, 2016, 8:09pm UTC](https://meta.discourse.org/t/issue-regarding-docker-development-image/53702/6 "2016-12-08T20:09:38Z")

</div>

For last few days I was looking into the Discourse’s code base and trying to understand it’s working so that I can make my hands dirty with some development and contribution. However, not being able to setup the development environment, I can’t do much. I hope @Falco will be able to resolve it sooner than later.

The commands that I listed in a sequence in my last post should be reproducible.

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [December 8, 2016, 8:58pm UTC](https://meta.discourse.org/t/issue-regarding-docker-development-image/53702/7 "2016-12-08T20:58:54Z")

</div>

> [@ibnesayeed](#):
>
> I hope @Falco will be able to resolve it sooner than later.

Sorry about that, we found a nasty bug with our memory allocation with lastest docker image and I’ll fix that before getting the dev image out.

I started looking at it tough, and it’s mostly done, we just need to get PostgreSQL to work.

---

<div class="post-metadata">

### Author: ![erlend\_sh](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/erlend_sh/32/119475_2.png) [@erlend\_sh](https://meta.discourse.org/u/erlend_sh)
#### Post date: [December 9, 2016, 12:14pm UTC](https://meta.discourse.org/t/issue-regarding-docker-development-image/53702/8 "2016-12-09T12:14:27Z")

</div>

> [@ibnesayeed](#):
>
> For last few days I was looking into the Discourse’s code base and trying to understand it’s working so that I can make my hands dirty with some development and contribution. However, not being able to setup the development environment, I can’t do much.

While it’s great that you’re testing the new Docker based workflow, keep in mind that this isn’t our default development environment yet. Our beginners guide for Ubuntu and Mac still work fine.

> [@Contributing to Discourse development](https://meta.discourse.org/t/discourse-development-contribution-guidelines/3823):
>
> bookmark This guide is designed for those who wish to contribute to the Discourse open-source project, detailing the setup and conventions necessary for effective collaboration. person_raising_hand Required user level: While anyone can contribute code, you will need to be familiar with Ruby and JavaScript. Summary This documentation will cover the following: Setting up your development environment Understanding where to begin contributing Creating and working with Discourse plugins Co…

---

<div class="post-metadata">

### Author: ![zuzust](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zuzust/32/120850_2.png) [@zuzust](https://meta.discourse.org/u/zuzust)
#### Post date: [December 9, 2016, 3:51pm UTC](https://meta.discourse.org/t/issue-regarding-docker-development-image/53702/9 "2016-12-09T15:51:25Z")

</div>

Meanwhile, I have setup a fullly functional and _standard_ Docker development environment, dockerizing the set of instructions in [Discourse Advanced Developer Install Guide](https://github.com/discourse/discourse/blob/master/docs/DEVELOPER-ADVANCED.md).

Check it out here: [https://github.com/adab1ts/discourse/commit/f2ff9aecf31794d032349646a3dfc8bd94387363](https://github.com/adab1ts/discourse/commit/f2ff9aecf31794d032349646a3dfc8bd94387363)

Changes in development workflow:

**Development**

```bash
First time:

$ docker-compose build
$ docker-compose run discourse bundle exec rake db:create db:migrate
$ docker-compose run discourse bundle exec rake admin:create
$ docker-compose up -d
$ docker-compose exec discourse mailcatcher --ip=0.0.0.0
$ docker-compose exec discourse bundle exec sidekiq -q critical,low,default -d -l log/sidekiq.log
$ docker-compose stop

Common workflow:

$ docker-compose start
$ docker-compose exec discourse mailcatcher --ip=0.0.0.0
$ docker-compose exec discourse bundle exec sidekiq -q critical,low,default -d -l log/sidekiq.log
$ docker-compose stop

```

**Test**

```bash
$ docker-compose run -e "RAILS_ENV=test" discourse bundle exec rake db:create db:migrate
$ docker-compose run discourse bundle exec rake autospec p l=5

```

To link services successfully you have to reference their names as host values in _config/database.yml_ and _config/discourse.{development,test}.conf_:

```plaintext
# config/discourse.development.conf

# comma delimited list of emails that have developer level access
developer_emails = carles@adabits.org

# redis server address
redis_host = redis

# redis server port
redis_port = 6379

# redis slave server address
redis_slave_host =

# redis slave server port
redis_slave_port = 6379

# redis database
redis_db = 0

# redis password
redis_password =

# redis sentinels eg
# redis_sentinels = 10.0.0.1:26381,10.0.0.2:26381
redis_sentinels =

```

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [December 10, 2016, 11:16pm UTC](https://meta.discourse.org/t/issue-regarding-docker-development-image/53702/10 "2016-12-10T23:16:52Z")

</div>

> FROM buildpack-deps:xenial

not using our base image loses out tons of the advantages of using docker in dev. We are super careful to include all the fiddly dependencies in our docker image including image magick, nginx and plenty of other bits and pieces.

compose is fine if that is your thing but you should base of our base image or `discourse/discourse` image.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [December 10, 2016, 11:19pm UTC](https://meta.discourse.org/t/issue-regarding-docker-development-image/53702/11 "2016-12-10T23:19:07Z")

</div>

> [@ibnesayeed](#):
>
> I too am interested in an official well maintained docker image for development where I can simply mount my working directory and map a port then land into the bash prompt of the container.

This sort of works, but there are some issues that need careful consideration. Especially the fact the UIDs inside docker do not necessarily the UIDs outside of docker, it is a delicate game that you need to play.

---

<div class="post-metadata">

### Author: ![ibnesayeed](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ibnesayeed/32/120427_2.png) [@ibnesayeed](https://meta.discourse.org/u/ibnesayeed)
#### Post date: [December 10, 2016, 11:36pm UTC](https://meta.discourse.org/t/issue-regarding-docker-development-image/53702/12 "2016-12-10T23:36:24Z")

</div>

> [@sam](#):
>
> This sort of works, but there are some issues that need careful consideration. Especially the fact the UIDs inside docker do not necessarily the UIDs outside of docker, it is a delicate game that you need to play.

I wrote that before I realized that there is a docker image for development that has some workflow in place already.

---

<div class="post-metadata">

### Author: ![zuzust](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zuzust/32/120850_2.png) [@zuzust](https://meta.discourse.org/u/zuzust)
#### Post date: [December 11, 2016, 12:18pm UTC](https://meta.discourse.org/t/issue-regarding-docker-development-image/53702/13 "2016-12-11T12:18:24Z")

</div>

It is just a temporary solution to face the issues reported in my first comment. I will adopt the official docker workflow as soon as it is fixed. In case you weren’t aware of, notice that `bin` folder is not being tracked by git ([discourse/.gitignore at main · discourse/discourse · GitHub](https://github.com/discourse/discourse/blob/master/.gitignore#L11)) so any changes to `bin/docker/boot_dev` are being ignored.

`discourse/discourse` image is not for development as it excludes the gems in _development group_ of Gemfile ([discourse\_docker/image/discourse/Dockerfile at master · adab1ts/discourse\_docker · GitHub](https://github.com/adab1ts/discourse_docker/blob/master/image/discourse/Dockerfile#L17)).

`discourse/base` is a bit time consuming to reason about, that’s why I followed the steps in your easy to follow [Discourse Advanced Developer Install Guide](https://github.com/discourse/discourse/blob/master/docs/DEVELOPER-ADVANCED.md).

But again, I’m not interested in my own way. As I said before, I will adopt the official docker workflow as soon as it is fixed.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [December 12, 2016, 7:06am UTC](https://meta.discourse.org/t/issue-regarding-docker-development-image/53702/14 "2016-12-12T07:06:45Z")

</div>

I spent some time cleaning stuff up today and have this all working.

Follow the instructions here and you should be good:

> <https://github.com/discourse/discourse/blob/main/bin/docker/README.md>

(if you tried this in the past try running `sudo rm -fr tmp/postgres` and `docker pull discourse/discourse_dev` to clean up stuff)

Let me know how you go.

---

<div class="post-metadata">

### Author: ![ibnesayeed](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ibnesayeed/32/120427_2.png) [@ibnesayeed](https://meta.discourse.org/u/ibnesayeed)
#### Post date: [December 12, 2016, 1:19pm UTC](https://meta.discourse.org/t/issue-regarding-docker-development-image/53702/15 "2016-12-12T13:19:31Z")

</div>

> [@sam](#):
>
> Let me know how you go.

It looks like the said image is still not in the DockerHub. Ideally it should be configured as an auto-build there.

```plaintext
$ ./bin/docker/rails s
Error response from daemon: No such container: discourse_dev

```

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [December 12, 2016, 1:20pm UTC](https://meta.discourse.org/t/issue-regarding-docker-development-image/53702/16 "2016-12-12T13:20:32Z")

</div>

Have you tried readme, step by step?

---

<div class="post-metadata">

### Author: ![ibnesayeed](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ibnesayeed/32/120427_2.png) [@ibnesayeed](https://meta.discourse.org/u/ibnesayeed)
#### Post date: [December 12, 2016, 1:44pm UTC](https://meta.discourse.org/t/issue-regarding-docker-development-image/53702/17 "2016-12-12T13:44:09Z")

</div>

> [@sam](#):
>
> Have you tried readme, step by step?

My bad, I missed the init step. I thought I did run that.

---

<div class="post-metadata">

### Author: ![ibnesayeed](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ibnesayeed/32/120427_2.png) [@ibnesayeed](https://meta.discourse.org/u/ibnesayeed)
#### Post date: [December 12, 2016, 2:15pm UTC](https://meta.discourse.org/t/issue-regarding-docker-development-image/53702/18 "2016-12-12T14:15:40Z")

</div>

> [@sam](#):
>
> Let me know how you go.

Worked smoothly like some fresh butter. @sam you are awesome!

On a side note, I read somewhere that it is good idea to run sidekiq and mailcatcher even in the dev mode. Should it be added to the Docker workflow as well?

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [December 12, 2016, 10:07pm UTC](https://meta.discourse.org/t/issue-regarding-docker-development-image/53702/19 "2016-12-12T22:07:53Z")

</div>

Good point, in general I simply disable `queue jobs` site setting in dev and avoid running sidekiq but you are right should be added, so I went ahead and added both 🙂

Also, to clean up usage I added a symlink to `bin/docker` called `d`

So:

```plaintext
d/mailcatcher
d/sidekiq
d/bundle install
... and so on work .. 

```

[https://github.com/discourse/discourse/commit/97e2a614c8587bbd9535ed28dc1bcf766751b2cc](https://github.com/discourse/discourse/commit/97e2a614c8587bbd9535ed28dc1bcf766751b2cc)

---

<div class="post-metadata">

### Author: ![ibnesayeed](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ibnesayeed/32/120427_2.png) [@ibnesayeed](https://meta.discourse.org/u/ibnesayeed)
#### Post date: [December 12, 2016, 10:26pm UTC](https://meta.discourse.org/t/issue-regarding-docker-development-image/53702/20 "2016-12-12T22:26:22Z")

</div>

This is awesome @sam. I am little curious about a command there though.

```plaintext
CMD="mailcatcher --http-ip 0.0.0.0 -f || (apt-get install -y libsqlite3-dev && gem install mailcatcher && mailcatcher --http-ip 0.0.0.0 -f)"

```

Why do we have a fallback (or ensuring) installation command here? Why can’t it be made sure in the Docker image beforehand?

[Next page](https://meta.discourse.org/t/issue-regarding-docker-development-image/53702.md?page=2)
