$ docker build -t executer:mysql .
Sending build context to Docker daemon 15.87 kB
Sending build context to Docker daemon
Step 0 : FROM debian:wheezy
#
# ... Many steps without error
#
Step 17 : RUN mysql_install_db --user=mysql --basedir=/usr/ --ldata=/var/lib/mysql/
---> Using cache
---> 1c71bf4524f0
Step 18 : RUN service mysql start
---> Running in b4643765b79b
......
MySQL Community Server 5.6.24 is started.
---> ac26b749a3c0
Removing intermediate container b4643765b79b
Successfully built ac26b749a3c0
$ docker run --rm -it executer:mysql /bin/bash
root@1d9208c19af0:/# mysql
ERROR 2002 (HY000): Cant connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (111)
root@1d9208c19af0:/# service mysql start
No directory, logging in with HOME=/
......
[info] MySQL Community Server 5.6.24 is started.
root@1d9208c19af0:/# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.24 MySQL Community Server (GPL)
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
FROM debian:wheezy
# add our user and group first to make sure their IDs get assigned consistently, regardless of whatever dependencies get added
RUN groupadd -r mysql && useradd -r -g mysql mysql
# FATAL ERROR: please install the following Perl modules before executing /usr/local/mysql/scripts/mysql_install_db:
# File::Basename
# File::Copy
# Sys::Hostname
# Data::Dumper
RUN apt-get update && apt-get install -y perl --no-install-recommends && rm -rf /var/lib/apt/lists/*
# gpg: key 5072E1F5: public key "MySQL Release Engineering <mysql-build@oss.oracle.com>" imported
RUN apt-key adv --keyserver pool.sks-keyservers.net --recv-keys A4A9406876FCBD3C456770C88C718D3B5072E1F5
ENV MYSQL_MAJOR 5.6
ENV MYSQL_VERSION 5.6.24
RUN echo "deb http://repo.mysql.com/apt/debian/ wheezy mysql-${MYSQL_MAJOR}" > /etc/apt/sources.list.d/mysql.list
# the "/var/lib/mysql" stuff here is because the mysql-server postinst doesn't have an explicit way to disable the mysql_install_db codepath besides having a database already "configured" (ie, stuff in /var/lib/mysql/mysql)
# also, we set debconf keys to make APT a little quieter
RUN { \
echo mysql-community-server mysql-community-server/data-dir select ''; \
echo mysql-community-server mysql-community-server/root-pass password ''; \
echo mysql-community-server mysql-community-server/re-root-pass password ''; \
echo mysql-community-server mysql-community-server/remove-test-db select false; \
} | debconf-set-selections \
&& apt-get update && apt-get install -y mysql-server="${MYSQL_VERSION}"* && rm -rf /var/lib/apt/lists/* \
&& rm -rf /var/lib/mysql && mkdir -p /var/lib/mysql
RUN apt-get update && apt-get install -y procps
# comment out a few problematic configuration values
RUN sed -Ei 's/^(bind-address|log)/#&/' /etc/mysql/my.cnf
# VOLUME /var/lib/mysql
# Install database
ADD ./database.sql /var/db/database.sql
# Set Standard settings
ENV user student
ENV password secret
ENV url file:/var/db/database.sql
ENV right READ
# Install starting script
ADD ./start-database.sh /usr/local/bin/start-database.sh
RUN chmod +x /usr/local/bin/start-database.sh
#EXPOSE 3306
RUN mysql_install_db --user=mysql --basedir=/usr/ --ldata=/var/lib/mysql/
RUN service mysql start
在运行容器之后,我应该如何更改我的Dockerfile以使其具有一个正在运行的MySQL服务?
我试过你的设置
参见https://github.com/bitplan/docker-stackoverflowanswers/tree/master/33299303
首先我得到了
E: Version '5.6.24*' for 'mysql-server' was not found
RUN apt-get install mysql-server-5.5
这是发行版特定的,所以我将FROM行改为
FROM ubuntu:14.04
这是我比较熟悉的
然后我修改了Dockerfile以更改
RUN service mysql start
至
CMD service mysql start
如michaelbahr的评论所述,并与
./run
而且
root@96ff34b4e0c0:/# service --status-all 2>&1 | grep mysql
[ ? ] mysql
我记得用过 几个月前没有问题地链接命令,但现在这不起作用了,我得到了以下输出: 什么改变了?如何在一行中删除所有Docker运行容器?如果有用的话,我正在Windows ;10上使用Docker for Windows(本机与Hyper-V一起使用,而不是与VirtualBox一起使用),我使用的命令在以前的Windows 8 Docker工具箱安装中运行良好。
如果我有一个mysql数据库在某台主机上运行,并且该主机也在运行docker容器:我将如何从主机上运行的docker容器中访问mysql数据库?。 有没有一种方法可以将主机端口发布到容器(与docker run-p的功能相反)?
我想简单地启动一个docker容器,它执行一些最终启动JBoss的java代码。 这工作得很好,除了我不知道如何再次连接到容器并回到bash提示符。 这是我启动容器的方式: 这是runAutomate.sh 现在,我必须在最后做尾部,以在容器完成运行我的自动化代码后保持其运行。最终的结果是Jboss在正确配置我的应用程序的情况下运行。 现在,当我再次尝试连接到容器时,我只得到一个没有提示的空白屏幕
我正在开发一个小应用程序,我想在Raspberry Pi上的docker容器中运行(模型4b,32bit,4GB RAM)。我目前正在学习Docker,到目前为止,我只在我的开发机器(一个mac)上构建和运行了一些东西。容器设置和罐子在那台机器上没有问题。 这是我非常基本的DockerFile: 正如你所看到的,没有什么进展。我想只是能够,然后运行我的容器。根据输出,生成成功,但运行失败,出现错误
问题内容: 这是我的问题: 我有一个任务在Amazon ECS上运行docker映像,但我想从容器的运行实例中创建一个新的docker映像。 我在Amazon Ecs上看到了实例的ID,我已经创建了AMI,但是我想创建一个新的docker image,可以从Amazon中提取它。 有任何想法吗 ? 问候和感谢 问题答案: 除了@Ben Whaley提供的答案外,我个人建议您 使用Docker AP
我正在使用Docker为Mac。我正在Docker容器中运行一个基于nodejs的微服务。我想通过浏览器测试节点微服务。如何获取正在运行的docker容器的IP地址?