Dockerfile
I am trying to play with Docker. This is my dockerfile:
FROM mysql:latest
ENV MYSQL_ROOT_PASSWORD 123
ENV MYSQL_DATABASE users
ENV MYSQL_USER admin
ENV MYSQL_PASSWORD 1234
ADD setup.sql /docker-entrypoint-initdb.d
EXPOSE 3306
CMD tail -f /dev/null
Access Mysql from container
And the following is my attempt to access to mysql from the container.
root@76757566f93a:/# mysql -uroot -p123 mysql: [Warning] Using a password on the command line interface can be insecure. ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
Makefile
Finally, .. this is a Makefile I use to run all docker commands:
container = db
image-name = senso
run:
docker run --name $(container) -d $(image-name)
bash:
docker exec -it $(container) /bin/bash
build:
docker build -t $(image-name) .
mysql -v
I've also tried to run mysql -v
to check if mysql is ok inside the container and I think is not.
root@76757566f93a:/# mysql -v ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)