简体   繁体   English

在backgroud中启动/ usr / bin / mysqld_safe

[英]start /usr/bin/mysqld_safe in backgroud

i´m running a container with docker and mysql. 我正在使用docker和mysql运行容器。 My image base is Ubuntu 16, the problem is when i execute /usr/bin/mysqld_safe --user=mysql --skip-grant-tables my terminal stays in black and i can´t type or do anithing inside. 我的映像库是Ubuntu 16,问题是当我执行/usr/bin/mysqld_safe --user=mysql --skip-grant-tables我的终端保持黑色,我无法在其中键入或执行任何操作。 Is there a way to execute this command and send the proceess to background? 是否可以执行此命令并将过程发送到后台? this container needs to execute commands and at the same time runing mysql in background. 这个容器需要执行命令,同时在后台运行mysql。

您可以在行的末尾添加& ,然后将其转到背景。

Manual 手册

Start docker container daemonized 启动Docker容器守护进程
docker run -d --name mysql <image> -- /usr/bin/mysqld_safe --user=mysql --skip-grant-tables

Connect to container and run commands: 连接到容器并运行命令:
docker exec -it mysql sh

Entrypoint 入口点

Common approach is to use an entrypoint script. 常用方法是使用入口点脚本。

#!/bin/sh
# entrypoint.sh

/usr/bin/mysqld_safe --user=mysql --skip-grant-tables &
# more commands etc.

set script as executable 将脚本设置为可执行文件

chmod 755 entrypoint.sh

Then in your Dockerfile: 然后在您的Dockerfile中:
ADD entrypoint.sh .
ENTRYPOINT ["./entrypoint.sh"]

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

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