![]() ![]() In short, Traefik won’t be able to determine the right container based on domain name. ![]() There are some technical reasons why the setup used for http endpoints won’t work for MySQL. Unfortunately, Traefik is not the optimal solution for us. That’s very annoying and we can do better! Configure a Docker port for MySQL Now we need to go to our database tool and change the connection settings before we can connect again. Only this time port 3306 is mapped to port 54122. CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMESĢbb260f8969e mysql:latest "docker-entrypoint.s…" 14 seconds ago Up 13 seconds 33060/tcp, 0.0.0.0:54122->3306/tcp mysqlĩa99e24681e8 httpd:2.4-alpine "httpd-foreground" 10 minutes ago Up 13 seconds 0.0.0.0:54123->80/tcp apache Let’s restart our containers and take another look at the output of running docker-compose ps. But there is an annoyance luring around the corner.Įvery now and then, we stop our containers and start them up again - perhaps daily - if we need to switch projects. Hurray! We have a container with MySQL running and we can connect to it through port 53900. ".entrypoints=web"Īfter running docker-compose up, we end up with the following docker containers running: CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMESĩa99e24681e8 httpd:2.4-alpine "httpd-foreground" 8 seconds ago Up 7 seconds 0.0.0.0:53901->80/tcp apacheĠbb272d37f00 mysql:latest "docker-entrypoint.s…" 8 seconds ago Up 7 seconds 33060/tcp, 0.0.0.0:53900->3306/tcp mysql Let’s take the demo `docker-compose` file from the last blog post, but this time we’ll also add a MySQL database: version: "3.8" This can be done for your http (and https) needs, but it’s also possible to have a similar setup for your database. ![]() That blog post described how to set up the Traefik proxy and route all your traffic to the correct container without having to rely on the ports exposed by your container. About a year ago, I wrote about managing your ports with Traefik in your local development environment. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |