I’m slowly getting used to Docker but I still have lots of struggle to understand how things work.
I also asked this question on Stack Overflow but it didn’t get much answers, so I’m trying my luck here!
I have a simple Laravel website that I dockerized to (try to) make my deployments easier. Here is my docker-compose.yml
version: '3'
services:
web:
build: .
env_file:
- .env.docker
depends_on:
- db
ports:
- '8000:80'
db:
image: mariadb:latest
restart: always
env_file:
- .env.mysql
ports:
- 3306
With this configuration, when I run docker-compose up --build
, my website is available at localhost:8000
. (I chose this because this isn’t my main website, and want to set this website in a subdomain by using Apache’s reverse proxy, everything works here)
So, on my local machine, when running docker-compose up --build
and waiting for the image to get built, after running docker ps
, I always get something like this:
![docker%20ps|690x29](upload://plqaGi701RDworNv8sSMoIuQEdL.png
After this, I push this image to Docker Hub, then pull it from a distant server and run it by doing the following:
docker run -d -p 8000:80 myusername/stadium
When running docker ps
on this distant server, here is what i get:
But when trying to run the migrations after running the container, I get the following error:
SQLSTATE[HY000] [2002] Connection refused
And when logging into my image (docker exec -ut <random_given_name> bash -l
), it returns me that the mysql command isn’t known.
My questions are:
- What’s happening here?
- Wasn’t the mariadb image supposed to be “inserted” into my final image when it got built?
- Do I need some more actions from the distant server when pulling the image?
- Is my database actually here but I’m doing something wrong?
“of course”, my database credentials are good, I checked them countless times and got some issues with them while setting everything up and finally got to the point where I could save things up locally in my running docker image.
Thank you in advance