tomsik68 / docker-xampp

Dockerfile to build an image containing XAMPP(MySQL + PHP + PHPMyAdmin) running on Debian system with SSH server
https://hub.docker.com/r/tomsik68/xampp/
MIT License
198 stars 109 forks source link

Connect to Docker's MySQL #22

Closed ndhuts closed 3 years ago

ndhuts commented 4 years ago

I used Macbook Pro. After running container, I tried to connect to MySQL inside the container with Navicat as follows :

I also tried to check container IP, and it gave me address 172.17.0.2. Changed host to that, and still didn't work.

I ran docker ps to check if 3306 is already exposed, and got this result, which I assume 3306 already opened and exposed CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES ed8bf8c550e9 tomsik68/xampp "sh /startup.sh" 45 minutes ago Up 45 minutes 3306/tcp, 0.0.0.0:41061->22/tcp, 0.0.0.0:41062->80/tcp myXampp

tomsik68 commented 4 years ago

Hi, can you try opening the website http://localhost:41062/ to see if the webserver works?

mejerome commented 3 years ago

Can you access mysql inside the container so I can import a file.sql through Dockerfile?

tomsik68 commented 3 years ago

Can you access mysql inside the container so I can import a file.sql through Dockerfile?

I think so. You need to perform two modifications to your Dockerfile. First, copy file.sql to the container and then import it via mysql command.

You can easily copy something into the container by adding for example: COPY file.sql /file.sql above the following line: https://github.com/tomsik68/docker-xampp/blob/3ab75a72b9eda7036a679b9231ea0772f1ef31f4/Dockerfile#L18

The sql import command should be appended somewhere below the following line (after xampp install): https://github.com/tomsik68/docker-xampp/blob/3ab75a72b9eda7036a679b9231ea0772f1ef31f4/Dockerfile#L21

tomsik68 commented 3 years ago

I'm closing the issue for now, if there's anything related you'd like to ask, feel free to reopen.