Docker Container Password?

image

I am a newbie to all of this. I have farmOS running on a vm (OCI) and when I try to set it up I am having DB connection issues. I decided that maybe I should build the mysql db in the docker container. But in order to do that it asks for a password? Anyone know what that password is?

Or if anyone has tips on connecting farmOS to the db that built on the vm outside of the docker container that would help too. I did some bind-address edits in my.cnf but that did not seem to help.

Thanks
jt

1 Like

i found the user root and test in the forums but now i get this error:

1 Like

Hi @jtgis, welcome to the forum! :slight_smile:

Can you describe some of the steps that you took to get to this point first? There are many ways to set up farmOS and its database in Docker.

If you are using the official MySQL Docker image it offers options for setting up the initial database user and password. See their docs here for more info: Docker

1 Like

Thanks for the welcome!

I am running it on an oracle cloud instance if that matters under ubuntu.

I followed up to this part of the install guide:

docker pull farmos/farmos:2.x.y
docker run --rm -p 80:80 -v "${PWD}/sites:/opt/drupal/web/sites" farmos/farmos:2.x.y

I also created a mysql db on my host machine, no docker.

My issue is when I am connecting to the db during setup:

It has no access.

This is all user error on my part but i am stumped on how to give the farmos container access to the db i made. I tried some bind-address stuff to get the docker ip in there but did not really understand what i was doing and it did not work.

If there is anyone around who has a make a db and set it up so that the farmos docker can access it for dummies guide it would be helpful :slight_smile:

1 Like

I might just follow the dev guide. This is for personal use so not much customization will happen. Although eventually I will try to add some x y z tiles to the map… ha

1 Like

Have you tried expanding the “Advanced options” and putting in a host/ip for the database? I think it defaults to “localhost” which I don’t think would work in this scenario because localhost from within the docker container wouldn’t point to where your DB is hosted.

Check out nginx - From inside of a Docker container, how do I connect to the localhost of the machine? - Stack Overflow - specifically the parts about host.docker.internal which is the preferred approach these days I believe.

3 Likes

Yea this is mainly a networking question. Think about the Docker container as one machine, and the host (where the database is installed) as a separate machine. They need to be able to talk to one another for the farmOS machine (the Docker container) to connect to the MySQL machine (the host container).

The way you have it set up is a little tricky, because from the perspective of the farmOS container, the host machine’s IP may change whenever you recreate the farmOS container. That is what host.docker.internal is meant to address… although as far as I know that only works with Docker for Mac/Windows, but you are on Ubuntu so it probably won’t work.

I might just follow the dev guide.

That will definitely be easier to set up, because it makes all the decisions about database container and networking for you. Since both the farmOS container and the database container (PostgreSQL in the case of the dev environment) are managed together via Docker Compose, they are accessible to one another within their own little network, with hostnames of www and db, respectively, so they can talk to one another.

I would not recommend using the dev environment for real data, however. The upgrade process is bumpier, so going from one version of farmOS to another will require more manual work to do.

You could also consider running MySQL/PostgreSQL in Docker in the same way that the dev environment is set up. You just need to start with the docker-compose.production.yml (renamed to docker-compose.yml) and add in a container for the database to that file.

You could start by coping in the db config from the dev environment config:

  db:
    image: postgres:12
    volumes:
      - './db:/var/lib/postgresql/data'
    ports:
      - '5432:5432'
    environment:
      POSTGRES_USER: farm
      POSTGRES_PASSWORD: farm
      POSTGRES_DB: farm

And maybe make the password a bit more secure. :slight_smile:

1 Like

Oh reading the link that @Symbioquine posted… maybe it is possible to use that on Linux now too! YMMV :slight_smile:

1 Like

I use 172.17.0.1 (default bridge address)
I’m sure I tried host.docker.internal and it wouldn’t work on Pi OS.

2 Likes

I think you may need use the “extra hosts” functionality to add the host.docker.internal alias. See the highlighted part;

e.g. I think it would be something like this;

docker run --add-host=host.docker.internal:host-gateway --rm -p 80:80 \
    -v "${PWD}/sites:/opt/drupal/web/sites" farmos/farmos:2.x.y

or

version: '3'
services:
  www:
    # Update this to the latest stable version before deploying.
    image: farmos/farmos:2.x.y
    volumes:
      - './sites:/opt/drupal/web/sites'
    ports:
      - '80:80'
    restart: always
    extra_hosts:
      - "host.docker.internal:host-gateway"
3 Likes

Ah, that’s possibly a step I left out,
but didn’t investigate it further since the bridge address worked.

2 Likes

This seems to be the solution to my issue!

Thank you all for the pertinent information. I decided to go with the dev setup instructions and everything is working.

I might try this method later so that I have my own db external to docker that I can sync to somewhere else easier maybe?

Next projects regarding my setup will be to get a custom xyz tile service to work as a basemap and setting up the uploaded file directory following the instructions. My plan is to do all of these processes enough times that I have the process down and simple and will share my documentation.

3 Likes