sameersbn / docker-mysql Goto Github PK
View Code? Open in Web Editor NEWA Dockerfile that installs a mysql server
License: MIT License
A Dockerfile that installs a mysql server
License: MIT License
Hi there,
I want to add some config to my.conf but "command not found".
So i need to install an editor like: vi, vim, nano but can't.
Can you help me check this..
I'm doing some test and i fall in truble.
If i create a table in mysql container and stop and then restart the table is still there.
I except that my table isn't there.
So my question is, why use data store? Could be some data loss?
Thanks
Thanks for providing this useful container.
I am doing a research aiming at finding issues in configuration files. I have a question about one MySQL config: max_binlog_cache_size
. It seems the official document says "The maximum recommended value is 4GB; this is due to the fact that MySQL currently cannot work with binary log positions greater than 4GB."
However, the default value is 18446744073709551615, which is much larger than the recommended value.
Shall we change the value to 4GB?
Thanks!
Would be great to have an optional environment variable or something like that to start mysql server with "event_scheduler" on.
It seems there is an issue with the mysql-server current version in the docker file because building an image give the following error.
E: Version '5.7.26*' for 'mysql-server' was not found
I have found on the official website that 5.7.26
is not available to download rather 5.7.28
is available. So, I have changed the version to MYSQL_VERSION=5.7.28
it worked flawlessly.
Docker host: CentOS 7
Docker version: 19.03.5
[user@hostname]$ docker info
Client:
Debug Mode: false
Server:
Containers: 11
Running: 0
Paused: 0
Stopped: 11
Images: 78
Server Version: 19.03.5
Storage Driver: devicemapper
Pool Name: docker-259:1-1668633-pool
Pool Blocksize: 65.54kB
Base Device Size: 10.74GB
Backing Filesystem: xfs
Udev Sync Supported: true
Data file: /dev/loop0
Metadata file: /dev/loop1
Data loop file: /var/lib/docker/devicemapper/devicemapper/data
Metadata loop file: /var/lib/docker/devicemapper/devicemapper/metadata
Data Space Used: 3.706GB
Data Space Total: 107.4GB
Data Space Available: 9.403GB
Metadata Space Used: 24.09MB
Metadata Space Total: 2.147GB
Metadata Space Available: 2.123GB
Thin Pool Minimum Free Space: 10.74GB
Deferred Removal Enabled: true
Deferred Deletion Enabled: true
Deferred Deleted Device Count: 0
Library Version: 1.02.158-RHEL7 (2019-05-13)
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: b34a5c8af56e510852c35414db4c1f4fa6172339
runc version: 3e425f80a8c931f88e6d94a8c831b9d5aa481657
init version: fec3683
Security Options:
seccomp
Profile: default
Kernel Version: 3.10.0-1062.7.1.el7.x86_64
Operating System: CentOS Linux 7 (Core)
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 1.758GiB
Name: hostname
ID: 6DJA:WYXO:337B:WV53:Y7BX:VGYO:M3MP:ZRAL:N3AA:SLKG:MWSV:O4EB
Docker Root Dir: /var/lib/docker
Debug Mode: false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
I have tried it with docker-cmd-line like docker run -ti -e ....
and run well, but run bad with docker-compose
mysql:
container_name: mysql-server
image: 'sameersbn/mysql:5.7.22-1'
restart: always
container_name: mysql
volumes:
- /srv/docker/data/mysqldata:/var/lib/mysql
ports:
- '3306:3306'
environment:
- DB_USER=admin007
- DB_PASS=myadmin@816
- DB_NAME=djsite
- DB_REMOTE_ROOT_NAME=root
- DB_REMOTE_ROOT_PASS=meigea@123
- MYSQL_CHARSET=utf8mb4
- MYSQL_COLLATION=utf8_bin
mysql exited with code 1
mysql | Creating database "djsite"...
mysql | ERROR 1253 (42000) at line 1: COLLATION 'utf8_bin' is not valid for CHARACTER SET 'utf8mb4'
mysql | Creating database "djsite"...
mysql | ERROR 1253 (42000) at line 1: COLLATION 'utf8_bin' is not valid for CHARACTER SET 'utf8mb4'
mysql | Creating database "djsite"...
mysql | ERROR 1253 (42000) at line 1: COLLATION 'utf8_bin' is not valid for CHARACTER SET 'utf8mb4'
mysql | Creating database "djsite"...
mysql | ERROR 1253 (42000) at line 1: COLLATION 'utf8_bin' is not valid for CHARACTER SET 'utf8mb4'
mysql | Creating database "djsite"...
mysql | ERROR 1253 (42000) at line 1: COLLATION 'utf8_bin' is not valid for CHARACTER SET 'utf8mb4'
mysql | Creating database "djsite"...
mysql | ERROR 1253 (42000) at line 1: COLLATION 'utf8_bin' is not valid for CHARACTER SET 'utf8mb4'
mysql | Creating database "djsite"...
mysql | ERROR 1253 (42000) at line 1: COLLATION 'utf8_bin' is not valid for CHARACTER SET 'utf8mb4'
mysql | Creating database "djsite"...
mysql | ERROR 1253 (42000) at line 1: COLLATION 'utf8_bin' is not valid for CHARACTER SET 'utf8mb4'
mysql | Creating database "djsite"...
mysql | ERROR 1253 (42000) at line 1: COLLATION 'utf8_bin' is not valid for CHARACTER SET 'utf8mb4'
Some of us need to change docker0 default network from 172.17.* to something else (like 192.168.*).
The "start" script could find out the network range in order not to hard code the granted permission on the database. Or maybe accept another value from a environment variable.
Hello
You write in the docu
You can access the mysql server as the root user using the following command:
docker run -it --rm --volumes-from=mysql sameersbn/mysql:latest mysql -uroot
im aware that you retrieve the socket from the mysql-volume /run/mysqld
. im just not sure if its safe to use this socket in two containers. maybe you can enlight me with some detailed explanation.
thanks in advance
thank you for this image.
i avoided using this image with docker-compose just to avoid the hassle of configuring remote access, so i combined this image with my own image in dockerfile like this:
ENV MYSQL_USER=mysql \
MYSQL_DATA_DIR=/var/lib/mysql \
MYSQL_RUN_DIR=/run/mysqld \
MYSQL_LOG_DIR=/var/log/mysql
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y mysql-server \
&& rm -rf ${MYSQL_DATA_DIR} \
&& rm -rf /var/lib/apt/lists/*
COPY mysql_entrypoint.sh /sbin/mysql_entrypoint.sh
and i start mysql server from supervisord:
[program:mysql]
command=/sbin/mysql_entrypoint.sh
autostart=true
autorestart=true
this is used to work, but docker crashed and after recreating the image i can't connect to mysql, it's asking for password
if there is a password what it is?:
additional info:
docker image: ubuntu:16.04
using docker for windows
Dear sir:
I use this command docker run -i -t --rm --link mysql:db sameersbn/mysql mysql -uroot -h db,it show errors: ERROR 1045 (28000): Access denied for user 'root'@'10.0.0.28' (using password: NO);
when I use this :docker run -i -t --rm --volumes-from=mysql sameersbn/mysql mysql -uroot, I can login to use mysql console.
I want to know what is different between two commands? thks!
Would it be possible to modify this image to accept a comma-separated array to DB_NAME
?
Such as: -e DB_NAME=dbname1,dbname2,dbname3
We have a use case where we have a Dockerized web application that needs to connect to about 5 different MySQL databases, and would like to only run a single MySQL container on our dev machines (via fig)
DB_REMOTE_ROOT_HOST defaults to 172.17.42.1 because docker0 used to have that ip by default. That's not the case anymore, see moby/moby#17305
Hello y launch a container mysql and i try to link to other container with apache and php, i want use phpmyadmin to see the databases ono mysql container, i launch and link the containers but phpmyadmin cant connect with mysql
Hello! I'm trying to create a Dockerfile that needs a MYSQL instance running on it. I'm fairly new to Docker in general, so apologizes in advance if I'm presenting some bad practices in here.
While trying to build the container it freezes (I killed after 8 minutes) on that last step. I tried to comment out the SQL creation of sys-main user but it just gave me another error.
Command ran: sudo docker-compose up
Output:
Step 12/15 : RUN /sbin/entrypoint.sh
---> Running in 0f30e5e37142
Installing database...
Starting MySQL server...
Waiting for database server to accept connections.
Creating debian-sys-maint user...
2019-04-04T00:50:10.890047Z mysqld_safe Logging to syslog.
2019-04-04T00:50:10.940056Z mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
Dockerfile (omiting non-relevant parts):
FROM tloriato/multichain-node:2.1.0
MAINTAINER tloriato
USER root
COPY entrypoint.sh /sbin/entrypoint.sh
ENV MYSQL_USER=mysql \
MYSQL_VERSION=5.7 \
MYSQL_DATA_DIR=/var/lib/mysql \
MYSQL_RUN_DIR=/run/mysqld \
MYSQL_LOG_DIR=/var/log/mysql
RUN apt-get update \
&& apt-get dist-upgrade \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y mysql-server-${MYSQL_VERSION} \
&& rm -rf ${MYSQL_DATA_DIR} \
&& rm -rf /var/lib/apt/lists/* \
/etc/init.d/mysql start
# run with a few apt-get things in here
RUN chmod 755 /sbin/entrypoint.sh
# run with some unzipping
# run installing python
ADD ./runexplorer.sh /root/runexplorer.sh
RUN /sbin/entrypoint.sh # I changed from ENTRYPOINT because the other one wasn't running!
RUN chmod a+x /root/runexplorer.sh
EXPOSE 3306/tcp
CMD ["/bin/bash", "/root/runexplorer.sh"]
docker-compose.yml (relevant parts only):
version: '2'
services:
explorernode:
build: ./explorer
stdin_open: true
tty: true
expose:
- 7557
- 8002
ports:
- "3306:3306"
environment:
DB_NAME: abe
DB_USER: abe
DB_PASS: PASSWORD
DB_REMOTE_ROOT_NAME: remote-user
DB_REMOTE_ROOT_PASS: remote-password
links:
- masternode
depends_on:
- masternode
Hi, i'm trying to start my container with docker-compose up but i get the error "ERROR 1133 (42000) at line 1: Can't find any matching row in the user table", after the container stops.
Docker version 18.06.1-ce, build e68fc7a
docker-compose version 1.22.0, build f46880f
Thanks for the help.
I have simply started mysql with following command for Redmine
docker run --name=mysql -d -e 'DB_NAME=redmine_production' -e 'DB_USER=redmine' -e 'DB_PASS=password' sameersbn/mysql:latest
I have not used --volume.
But now i need backup of database because I can not afford loosing database.
Plz help. How can i do it?
Using the example from the readme:
docker run --name mysql -d \
-e 'DB_NAME=dbname' sameersbn/mysql:latest
Results:
# docker logs mysql
Installing database...
Could not connect to mysql server. Aborting...
Seems to be a permissions error on /tmp/:
root@core01:~# docker run --name mysql -it -e 'DB_NAME=dbname' sameersbn/mysql:latest bash
/root@bcefdfcb16b1:/# chmod 777 /tmp
root@bcefdfcb16b1:/# /sbin/entrypoint.sh &
[1] 25
root@bcefdfcb16b1:/# Installing database...
Starting MySQL server...
Waiting for database server to accept connections..
Creating debian-sys-maint user...
Creating database "dbname"...
151001 06:52:13 mysqld_safe Logging to syslog.
151001 06:52:13 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
root@bcefdfcb16b1:/# ps -ejHf
UID PID PPID PGID SID C STIME TTY TIME CMD
root 1 0 1 1 0 06:51 ? 00:00:00 bash
root 25 1 25 1 0 06:52 ? 00:00:00 /bin/sh /usr/bin/mysqld_safe
mysql 1228 25 25 1 1 06:52 ? 00:00:00 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib/mysql/plugin --user=mysql --pid-file=/var/run/mysqld/mysqld.pid --socket=/var/run/mysqld/mysqld.sock
root 1229 25 25 1 0 06:52 ? 00:00:00 logger -t mysqld -p daemon.error
root 1247 1 1247 1 0 06:52 ? 00:00:00 ps -ejHf
root@bcefdfcb16b1:/#
And without the chmod step:
root@core01:~# docker run --name mysql -it -e 'DB_NAME=dbname' sameersbn/mysql:latest bash
root@fae184744de6:/# /sbin/entrypoint.sh &
[1] 25
root@fae184744de6:/# Installing database...
[1]+ Exit 1 /sbin/entrypoint.sh
root@fae184744de6:/# /sbin/entrypoint.sh &
[1] 84
Could not connect to mysql server. Aborting...
[1]+ Exit 1 /sbin/entrypoint.sh
root@fae184744de6:/#
I'm using Docker version 1.7.1, build 786b29d
Thanks for this dockerfile @sameersbn have a cookie @changetip
I restart my mysql containers, according to the 'docker logs - tf mysql' command to check the log information to quote the following error:
Could not connect to mysql server. Aborting...
Could you tell me what could be the cause?
Hi,
Why do not you create releases ?
Thanks for great job !
I am getting the bellow error over and over I have tried stating a fresh container with no databases tried using my old databases and the same thing happens, I have tried deleting log files as suggested on a forum but no change, I have downloaded a new image I even tried building it myself can't find anyone with this issue in a docker container.
141213 16:17:18 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
Hi,
Thanks for this great image. I use it in connection with gitlab image you also created. I run the mysql with a data container to keep the mysql data in a data container. I am wondering what is the best way to backup the whole Database ?
Thanks a lot
Hi, when I follow the commands to start the MySQL container/daemon:
docker run -name mysql -d sameersbn/mysql:latest
and try to get the IP address
MYSQL_IP=$(docker inspect mysql | grep IPAddres | awk -F'"' '{print $4}')
But I am receiving an empty (MYSQL_IP) address.
What am I missing?
Thanks.
Below is the full "inspect" output from mysql container:
[{
"ID": "58e2feb006a8115659e5963a18e36f380daa2ebef5f859998e9fd164d6ee6060",
"Created": "2014-07-24T11:42:06.149458819Z",
"Path": "/start",
"Args": [],
"Config": {
"Hostname": "58e2feb006a8",
"Domainname": "",
"User": "",
"Memory": 0,
"MemorySwap": 0,
"CpuShares": 0,
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"PortSpecs": null,
"ExposedPorts": {
"3306/tcp": {}
},
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"HOME=/",
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"DEBIAN_FRONTEND=noninteractive"
],
"Cmd": [
"/start"
],
"Dns": [
"8.8.8.8",
"8.8.4.4"
],
"Image": "sameersbn/mysql:latest",
"Volumes": {
"/var/lib/mysql": {}
},
"VolumesFrom": "",
"WorkingDir": "",
"Entrypoint": null,
"NetworkDisabled": false,
"OnBuild": null
},
"State": {
"Running": false,
"Pid": 0,
"ExitCode": 1,
"StartedAt": "2014-07-24T11:42:06.256444663Z",
"FinishedAt": "2014-07-24T11:42:06.443349565Z",
"Ghost": false
},
"Image": "931eb2b8bba4856ee2ded254661a40b5c56b3d505c49b19670b748418dd1c827",
"NetworkSettings": {
"IPAddress": "",
"IPPrefixLen": 0,
"Gateway": "",
"Bridge": "",
"PortMapping": null,
"Ports": null
},
"ResolvConfPath": "/var/lib/docker/containers/58e2feb006a8115659e5963a18e36f380daa2ebef5f859998e9fd164d6ee6060/resolv.conf",
"HostnamePath": "/var/lib/docker/containers/58e2feb006a8115659e5963a18e36f380daa2ebef5f859998e9fd164d6ee6060/hostname",
"HostsPath": "/var/lib/docker/containers/58e2feb006a8115659e5963a18e36f380daa2ebef5f859998e9fd164d6ee6060/hosts",
"Name": "/trusting_mclean",
"Driver": "aufs",
"ExecDriver": "native-0.1",
"Volumes": {
"/var/lib/mysql": "/var/lib/docker/vfs/dir/21b0edbba3d0a376db035c91b4484560db388c61cf8f9f56dd75191242214a9d"
},
"VolumesRW": {
"/var/lib/mysql": true
},
"HostConfig": {
"Binds": null,
"ContainerIDFile": "",
"LxcConf": [],
"Privileged": false,
"PortBindings": {
"3306/tcp": null
},
"Links": null,
"PublishAllPorts": false
}
}]
Trying to get a shell in the docker using
docker run -it --rm --volumes-from=mysql sameersbn/mysql:latest mysql -uroot
causes
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
Mount a file to the container? Maybe that's too complicate.
Like init scripts.
@sameersbn and team
Kindly have a look at #sameersbn/docker-gitlab#1486
After docker-compose pull, I am getting the following error
mysql_1 | Creating database "gitlabhq_production"...
mysql_1 | Granting access to database "gitlabhq_production" for user "gitlab"...
mysql_1 | ERROR 3009 (HY000) at line 1: Column count of mysql.user is wrong. Expected 45, found 42. Created with MySQL 50554, now running 50721. Please use mysql_upgrade to fix this error.
Request to add USERMAP_UID, and USERMAP_GID like sameersbn/docker-gitlab.
There is two problems with this installation for remote access.
I have a very old image that was installed using the :latest tag
I am trying to take it up to something more recent, however with all the tags that I found on docker hub I have this error message (version is different with different tags):
ERROR 3009 (HY000) at line 1: Column count of mysql.user is wrong. Expected 45, found 42. Created with MySQL 50554, now running 50724. Please use mysql_upgrade to fix this error.
I am unable to run the mysql_upgrade command inside the docker container because the image stops.
There is an easy way for recover this situation?
Question: shouldn't the mysql_upgrade taken into consideration when mysql version changes?
Thank you in advance
I have installed it to my Synology, but how do I create a database and credentials?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.