mirror of https://github.com/docker/docs.git
Fixed Dockerfile and compose
This commit is contained in:
parent
1bef68654e
commit
e98a25c94f
|
|
@ -72,7 +72,7 @@ func main() {
|
||||||
trust = signed.NewEd25519()
|
trust = signed.NewEd25519()
|
||||||
}
|
}
|
||||||
|
|
||||||
db, err := sql.Open("mysql", "dockercondemo:dockercondemo@tcp(mysql:3306)/dockercondemo")
|
db, err := sql.Open("mysql", "dockercondemo:dockercondemo@tcp(vetinarimysql:3306)/dockercondemo")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Fatal("Error starting DB driver: ", err.Error())
|
logrus.Fatal("Error starting DB driver: ", err.Error())
|
||||||
return // not strictly needed but let's be explicit
|
return // not strictly needed but let's be explicit
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
vetinari:
|
vetinari:
|
||||||
build: .
|
build: .
|
||||||
links:
|
links:
|
||||||
- mysql
|
- vetinarimysql
|
||||||
ports:
|
ports:
|
||||||
- "8080:8080"
|
- "8080:8080"
|
||||||
- "4443:4443"
|
- "4443:4443"
|
||||||
|
|
@ -10,7 +10,7 @@ vetinari:
|
||||||
# - /dev/bus/usb/003/010:/dev/bus/usb/002/010
|
# - /dev/bus/usb/003/010:/dev/bus/usb/002/010
|
||||||
# - /var/run/pcscd/pcscd.comm:/var/run/pcscd/pcscd.comm
|
# - /var/run/pcscd/pcscd.comm:/var/run/pcscd/pcscd.comm
|
||||||
# build: ../rufus
|
# build: ../rufus
|
||||||
mysql:
|
vetinarimysql:
|
||||||
build: ./mysql/
|
build: ./vetinarimysql/
|
||||||
ports:
|
ports:
|
||||||
- "3306:3306"
|
- "3306:3306"
|
||||||
|
|
|
||||||
1
mysql
1
mysql
|
|
@ -1 +0,0 @@
|
||||||
Subproject commit 3234be9a899bbb86cbf724901d4cfe3b72789285
|
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
FROM sameersbn/ubuntu:14.04.20150613
|
||||||
|
MAINTAINER diogo@docker.com
|
||||||
|
|
||||||
|
RUN apt-get update \
|
||||||
|
&& apt-get install -y mysql-server \
|
||||||
|
&& rm -rf /var/lib/mysql/mysql \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
ADD start /start
|
||||||
|
RUN chmod 755 /start
|
||||||
|
|
||||||
|
EXPOSE 3306
|
||||||
|
|
||||||
|
CMD ["/start"]
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2014 Sameer Naik
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
|
|
@ -0,0 +1,127 @@
|
||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
DB_NAME='dockercondemo'
|
||||||
|
DB_TABLE='tuf_files'
|
||||||
|
DB_USER='dockercondemo'
|
||||||
|
DB_PASS='dockercondemo'
|
||||||
|
|
||||||
|
DB_REMOTE_ROOT_NAME='dockercondemo'
|
||||||
|
DB_REMOTE_ROOT_PASS='dockercondemo'
|
||||||
|
DB_REMOTE_ROOT_HOST=''
|
||||||
|
|
||||||
|
# disable error log
|
||||||
|
sed 's/^log_error/# log_error/' -i /etc/mysql/my.cnf
|
||||||
|
|
||||||
|
# Fixing StartUp Porblems with some DNS Situations and Speeds up the stuff
|
||||||
|
# http://www.percona.com/blog/2008/05/31/dns-achilles-heel-mysql-installation/
|
||||||
|
cat > /etc/mysql/conf.d/mysql-skip-name-resolv.cnf <<EOF
|
||||||
|
[mysqld]
|
||||||
|
skip_name_resolve
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# fix permissions and ownership of /var/lib/mysql
|
||||||
|
mkdir -p -m 700 /var/lib/mysql
|
||||||
|
chown -R mysql:mysql /var/lib/mysql
|
||||||
|
|
||||||
|
# fix permissions and ownership of /run/mysqld
|
||||||
|
mkdir -p -m 0755 /run/mysqld
|
||||||
|
chown -R mysql:root /run/mysqld
|
||||||
|
|
||||||
|
#
|
||||||
|
# the default password for the debian-sys-maint user is randomly generated
|
||||||
|
# during the installation of the mysql-server package.
|
||||||
|
#
|
||||||
|
# Due to the nature of docker we blank out the password such that the maintenance
|
||||||
|
# user can login without a password.
|
||||||
|
#
|
||||||
|
sed 's/password = .*/password = /g' -i /etc/mysql/debian.cnf
|
||||||
|
|
||||||
|
# initialize MySQL data directory
|
||||||
|
if [ ! -d /var/lib/mysql/mysql ]; then
|
||||||
|
echo "Installing database..."
|
||||||
|
mysql_install_db --user=mysql >/dev/null 2>&1
|
||||||
|
|
||||||
|
# start mysql server
|
||||||
|
echo "Starting MySQL server..."
|
||||||
|
/usr/bin/mysqld_safe >/dev/null 2>&1 &
|
||||||
|
|
||||||
|
# wait for mysql server to start (max 30 seconds)
|
||||||
|
timeout=30
|
||||||
|
echo -n "Waiting for database server to accept connections"
|
||||||
|
while ! /usr/bin/mysqladmin -u root status >/dev/null 2>&1
|
||||||
|
do
|
||||||
|
timeout=$(($timeout - 1))
|
||||||
|
if [ $timeout -eq 0 ]; then
|
||||||
|
echo -e "\nCould not connect to database server. Aborting..."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo -n "."
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
echo
|
||||||
|
|
||||||
|
## create a localhost only, debian-sys-maint user
|
||||||
|
## the debian-sys-maint is used while creating users and database
|
||||||
|
## as well as to shut down or starting up the mysql server via mysqladmin
|
||||||
|
echo "Creating debian-sys-maint user..."
|
||||||
|
mysql -uroot -e "GRANT ALL PRIVILEGES on *.* TO 'debian-sys-maint'@'localhost' IDENTIFIED BY '' WITH GRANT OPTION;"
|
||||||
|
|
||||||
|
if [ -n "${DB_REMOTE_ROOT_NAME}" -a -n "${DB_REMOTE_ROOT_HOST}" ]; then
|
||||||
|
echo "Creating remote user \"${DB_REMOTE_ROOT_NAME}\" with root privileges..."
|
||||||
|
mysql -uroot \
|
||||||
|
-e "GRANT ALL PRIVILEGES ON *.* TO '${DB_REMOTE_ROOT_NAME}'@'${DB_REMOTE_ROOT_HOST}' IDENTIFIED BY '${DB_REMOTE_ROOT_PASS}' WITH GRANT OPTION; FLUSH PRIVILEGES;"
|
||||||
|
fi
|
||||||
|
|
||||||
|
/usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf shutdown
|
||||||
|
fi
|
||||||
|
|
||||||
|
# create new user / database
|
||||||
|
if [ -n "${DB_USER}" -o -n "${DB_NAME}" ]; then
|
||||||
|
/usr/bin/mysqld_safe >/dev/null 2>&1 &
|
||||||
|
|
||||||
|
# wait for mysql server to start (max 30 seconds)
|
||||||
|
timeout=30
|
||||||
|
while ! /usr/bin/mysqladmin -u root status >/dev/null 2>&1
|
||||||
|
do
|
||||||
|
timeout=$(($timeout - 1))
|
||||||
|
if [ $timeout -eq 0 ]; then
|
||||||
|
echo "Could not connect to mysql server. Aborting..."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ -n "${DB_NAME}" ]; then
|
||||||
|
for db in $(awk -F',' '{for (i = 1 ; i <= NF ; i++) print $i}' <<< "${DB_NAME}"); do
|
||||||
|
echo "Creating database \"$db\"..."
|
||||||
|
mysql --defaults-file=/etc/mysql/debian.cnf \
|
||||||
|
-e "CREATE DATABASE IF NOT EXISTS \`$db\` DEFAULT CHARACTER SET \`utf8\` COLLATE \`utf8_unicode_ci\`;"
|
||||||
|
if [ -n "${DB_USER}" ]; then
|
||||||
|
echo "Granting access to database \"$db\" for user \"${DB_USER}\"..."
|
||||||
|
mysql --defaults-file=/etc/mysql/debian.cnf \
|
||||||
|
-e "GRANT ALL PRIVILEGES ON \`$db\`.* TO '${DB_USER}' IDENTIFIED BY '${DB_PASS}';"
|
||||||
|
fi
|
||||||
|
# Create our Database:
|
||||||
|
mysql -uroot -e "USE \`$db\`; DROP TABLE IF EXISTS \`$DB_TABLE\`;"
|
||||||
|
mysql -uroot -e "USE \`$db\`; CREATE TABLE \`$DB_TABLE\` (
|
||||||
|
\`id\` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
|
\`qdn\` varchar(255) NOT NULL,
|
||||||
|
\`role\` varchar(255) NOT NULL,
|
||||||
|
\`version\` int(11) NOT NULL,
|
||||||
|
\`data\` longblob NOT NULL,
|
||||||
|
PRIMARY KEY (\`id\`),
|
||||||
|
UNIQUE KEY \`qdn\` (\`qdn\`,\`role\`,\`version\`)
|
||||||
|
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;"
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
/usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf shutdown
|
||||||
|
fi
|
||||||
|
|
||||||
|
# listen on all interfaces
|
||||||
|
cat > /etc/mysql/conf.d/mysql-listen.cnf <<EOF
|
||||||
|
[mysqld]
|
||||||
|
bind = 0.0.0.0
|
||||||
|
EOF
|
||||||
|
|
||||||
|
exec /usr/bin/mysqld_safe
|
||||||
Loading…
Reference in New Issue