简体   繁体   English

在CentOS7上使用Debian基础运行MySQL docker映像

[英]Running MySQL docker image, using a Debian base, on CentOS7

I've pulled MySQL image from docker hub and tried to run it using 我已经从docker hub提取MySQL映像并尝试使用

docker run (-i) (-t) -d -p 3306:3306 --name test-mysql -e MYSQL_ROOT_PASSWORD=password -d mysql:latest —innodb_buffer_pool_size=1G —character-set-server=utf8 —collation-server=utf8_general_ci —lower_case_table_names=1

but the container exits immediately. 但是容器会立即退出。 Output for docker ps is empty while output for docker ps -a is: docker ps输出为空,而docker ps -a输出为:

CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                       PORTS               NAMES
93ffbf44b3c6        mysql:latest        "docker-entrypoint..."   9 seconds ago       Exited (127) 8 seconds ago                       test-mysql

docker images

REPOSITORY                TAG                 IMAGE ID            CREATED             SIZE
centos/mysql-56-centos7   latest              1d5bc23ca83b        25 hours ago        401MB
mysql                     latest              11615e225c92        5 days ago          408MB

I'm running docker on CentOS on AWS and from MySQL's Docker file I can see that the image uses a Debian base. 我在AWS的CentOS上运行docker,并从MySQL的Docker文件中看到该映像使用Debian基础。

I've also tried to run the image both on the foreground and the background but neither seem to work. 我也尝试过在前景和背景上都运行图像,但是似乎都没有用。

I've tried using a CentOS base as well but even this exits immediately. 我也尝试过使用CentOS基础 ,但即使这样也会立即退出。

I'm running docker as root. 我以root身份运行docker。

First things first. 首先是第一件事。 It doesn't matter what OS you're running. 您在运行什么操作系统都没有关系。 It doesn't matter which OS is the image build on. 映像建立在哪个OS上都没有关系。 That's the power of Docker. 这就是Docker的力量。 You can run CentOS-based container in Ubuntu and vice versa. 您可以在Ubuntu中运行基于CentOS的容器,反之亦然。

If container exited, there was some error while running processes inside the container. 如果容器退出,则在容器内运行进程时会出现一些错误。 Code 128 is too ambiguous. 代码128太含糊。 To find out what really prevent you from running MySQL container take a look at container logs: 要找出真正阻止您运行MySQL容器的原因,请查看容器日志:

docker logs [containerId]

The error was on the run command itself. 错误在于运行命令本身。 Double instead of single dashes should have been used for overriding database configuration properties. 应该使用双破折号代替单破折号来覆盖数据库配置属性。 So the correct docker run command is the following 所以正确的docker run命令如下

docker run -d -p 3306:3306 --name test-mysql -e MYSQL_ROOT_PASSWORD=password -d mysql:latest --innodb_buffer_pool_size=1G --character-set-server=utf8 --collation-server=utf8_general_ci --lower_case_table_names=1

Thanks for the hint @Sergey Kovalev 感谢您的提示@Sergey Kovalev

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM