Connect new container to an existing container


Recommended Posts

Out of the box install, first time trying Unraid.

 

It seems there is a `bridge` network called "docker0". I have created containers from the official `mariadb` and `phpmysql` images, both connected to this default network.

 

In the `phpmyadmin` container, the hostname I put the same container name from the other, "mariadb". It does not connect between them.

 

both have the `--net='bridge'` in their docker run command.

 

Does Unraid have a different approach?

 

Link to comment

Are the `'--net=..."` and `"--network=..."` commands the same / equal?

 

I have it in my PHPMyAdmin container, from the output of the Unraid UI to deploy this from the "Apps" repository.


 

docker run
  -d
  --name='phpmyadmin'
  --net='bridge'
  -e TZ="Europe/London"
  -e HOST_OS="Unraid"
  -e HOST_HOSTNAME="Tower"
  -e HOST_CONTAINERNAME="phpmyadmin"
  -e 'MYSQL_USER'='root'
  -e 'MYSQL_PASSWORD'='password'
  -e 'PMA_HOST'='mariadb'
  -e 'PMA_PORT'='3306'
  -l net.unraid.docker.managed=dockerman
  -l net.unraid.docker.webui='http://[IP]:[PORT:80]'
  -l net.unraid.docker.icon='https://secure.gravatar.com/avatar/4be7d922dc46f22e6b0cf1162f0e329b.jpg'
  -p '8080:80/tcp' 'phpmyadmin/phpmyadmin' 

 

Or is the Unraid not deploying this as I am expecting? If I supply "--network=docker0" (for example), the documentation suggests the Docker Engine provides the ongoing management of container to assigned IP address and publishes it in the local container's `/etc/hosts` file.

 

Or am I missing more config?


 

Link to comment

If I hard-code the mariadb container's IP address on the same "bridge" network, it connects.

 

How can I configure this container to use Docker-based DNS to identify the DB container? It should automatically track any IP address changes of the containers themselves.

 

I am sure this is the purpose of the "--network" switch in a `docker run` command is to allow a local-network lookup? Or are extra parameters required?

 

 

Link to comment

Final research from today... Can I sense check with others how the official docs describe networking?

Quote

 

Configuring a container

Network Type

If the Bridge type is selected, the application’s network access will be restricted to only communicating on the ports specified in the port mappings section. If the Host type is selected, the application will be given access to communicate using any port on the host that isn't already mapped to another in-use application/service. Generally speaking, it is recommended to leave this setting to its default value as specified per application template.

 

 

Host use-cases should be tiny, and not for my use-case. I am asking about the service discovery (DNS) part of containers when using Docker with Unraid,

 

 

Edited by explosionhole
Link to comment

Some research against the Docker documentation, custom (user) created networks allow for additional container hostname lookups across the network - precisely what I need.

 

at the main "tower.local" console (from the GUI's top-right options), I issued:

 

docker network create main-net

 

I re-created the MariaDB-Official and PHPMyAdmin containers, both connected to this new `main-net` network.

 

In the PHPMySQLAdmin, I was still specifying "mariadb" (the name of the mariadb container) under the `MYSQL_HOST` field. When I try to connect, it still errors and if I look in the MySQL's log file, I see:

 

Quote

Access denied for user 'root'@'172.18.0.3' (using password: YES)

 

Which suggests the correct container (mariadb) IS being hit with the PHPMyAdmin login request. The MariaDB user is specifically using the

@'172.18.0.3'

as part of the connection string.

 

To test this, I redeployed the PHPMyAdmin container, hard-coding the `mariadb` container's IP address (172.18.0.2). Now it logs in fine! But I have hard-coded.

 

If I go to the `mariadb` User Accounts section, these are the default users in my setup:

 

SCR-20230201-e43.thumb.png.6bd2a0d27a9ef438ddadfdd3d35d679d.png

 

I created a NEW user, with a specific "Host name" entry of the PHPMyAdmin container, 172.18.0.3 (to mimic the log file entry I saw).

 

image.thumb.png.e04d1ea3082b4de37efe43edab7a9551.png

 

Then I redeploy the PHPMyAdmin container to use the `mariadb` as the MYSQL_HOST entry. Retrying the PHPMyAdmin login, which is successful.

 

Why is the 'root'@'%' not being applied to my authentication, to cover the scenario of `'root'@'172.18.0.3'`? I thought this was the point of this configuration?

 

 

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.