在centos中设置Docker_Opts [英] Set Docker_Opts in centos

查看:295
本文介绍了在centos中设置Docker_Opts的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将docker设置为在运行Amazon Linux(centos)的主机上侦听tcp://0.0.0.0/4243。我看过的所有文档都告诉我运行以下命令

I need to set docker to listen to tcp://0.0.0.0/4243 on my host machine running amazon linux (centos). All the documentation I have seen has told me to run the following command

echo DOCKER_OPTS="-H=tcp://127.0.0.1:4243" >> /etc/default/docker

这会将正确的docker_opts写入/ etc / default / docker。我已经做到了,但是当我重新启动docker时,它不会监听127.0.0.1

Which will write the correct docker_opts to /etc/default/docker. I've done this, but when I restart docker it does not listen to 127.0.0.1

我可以通过输入

sudo /usr/bin/docker -H tcp://0.0.0.0:4243 -d &

可以,但是我希望默认选项在tcp://0.0.0.0上监听: 4243,而不必每次都指定它。

That works, but I want the default option to be listening on tcp://0.0.0.0:4243 without having to specify it every time.

似乎docker完全忽略了我的/ etc / default / docker文件,因此设置被忽略了。我还尝试将文件写入/etc/default/docker.io和/ etc / default / docker-io(真的没有发生太多事情)

It seems that docker is completely ignoring my /etc/default/docker file so the settings are being ignored. I also tried writing the file to /etc/default/docker.io and /etc/default/docker-io (didn't really expect much to happen)

I需要能够仅用

service docker start

否则会在我当前的部署手册中引起问题。

or it will cause issues in my current deployment playbook.

任何关于设置方法的想法

Any thoughts on what I can do to set DOCKER_OPTS and not have to do it every time I restart docker?

推荐答案

在RHEL7中使用DOCKER_OPTS,而不是每次都重新启动docker时不必这样做吗,而不是修改docker.service单位文件,您也可以只编辑/ etc / sysconfig / docker文件:

In RHEL7, instead of modifying your docker.service unit file, you can also just edit your /etc/sysconfig/docker file:

# /etc/sysconfig/docker

# Modify these options if you want to change the way the docker daemon runs
OPTIONS=--selinux-enabled -H unix:///var/run/docker.sock -H tcp://0.0.0.0:4243

,然后重新启动docker服务。

and then restart your docker service.

对我来说,这比修改服务脚本更可靠。

To me, this is more reliable than modifying the service script.

这篇关于在centos中设置Docker_Opts的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆