Reputation: 193
I have a Dockerfile that is based FROM php:alpine
and I'm trying to add mysql to the build.
FROM php:alpine
COPY test-data/ /var/www/
RUN apk add --update --no-cache \
mysql
# Composer
RUN curl -s https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin/ --filename=composer
ENV COMPOSER_ALLOW_SUPERUSER=1
WORKDIR /var/www
My problem is after successfully building, I tried and run the container with the mysql environment overrides but I cant login to mysql within the container.
$ docker run -e MYSQL_DATABASE=homestead -e MYSQL_USER=homestead -e MYSQL_PASSWORD=secret -e MYSQL_ROOT_PASSWORD=secret -ti --rm idecardo /bin/sh
Testing mysql login fails
$ mysql -uroot -p # with password "secret"
Upvotes: 0
Views: 278
Reputation: 756
Since you are newbie - always try to learn by copying ready working code over and breaking down what is being done in that code.
For Docker:
In general:
Since you want php and mysql to work from docker - my advise is for you to see about docker-compose. Docker containers can be run in a variety of ways and docker-compose allows you to launch several docker containers, share some folders between them. In that scenario you would want to launch separate mysql container and separate php container, share host data folders between them and launch your code.
Also, watch some video tutorials online - they explain in details the basics of what docker is all about and how it works.
Upvotes: 1