[root@vm-240010 yaml]# docker-compose  up -d
zcbuszookeeper is up-to-date
Starting zcbusvue ...
zcbusdb is up-to-date
zcbuskafka is up-to-date
zcbusrestapi is up-to-date
zcbus is up-to-date
zc03 is up-to-date
zc01 is up-to-date
zc02 is up-to-date

ERROR: for zcbusvue  a bytes-like object is required, not 'str'

ERROR: for zcbusvue  a bytes-like object is required, not 'str'
Traceback (most recent call last):
  File "site-packages/docker/api/client.py", line 261, in _raise_for_status
  File "site-packages/requests/models.py", line 940, in raise_for_status
requests.exceptions.HTTPError: 500 Server Error: Internal Server Error for url: http+docker://localhost/v1.22/containers/2c360aba76993296fa63be2fde4f490a4682c119e178e0291ed7497c50aa3e8b/start

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "compose/service.py", line 625, in start_container
  File "compose/container.py", line 241, in start
  File "site-packages/docker/utils/decorators.py", line 19, in wrapped
  File "site-packages/docker/api/container.py", line 1095, in start
  File "site-packages/docker/api/client.py", line 263, in _raise_for_status
  File "site-packages/docker/errors.py", line 31, in create_api_error_from_http_exception
docker.errors.APIError: 500 Server Error: Internal Server Error ("b'driver failed programming external connectivity on endpoint zcbusvue (ee078761e4d2c313a376eccbc9f4c408d2868d2afadfaf85cb216a9a3ca963b7):  (iptables failed: iptables --wait -t nat -A DOCKER -p tcp -d 0/0 --dport 8890 -j DNAT --to-destination 172.18.0.5:80 ! -i br-4909274ee71d: iptables: No chain/target/match by that name.\n (exit status 1))'")

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "bin/docker-compose", line 6, in <module>
  File "compose/cli/main.py", line 71, in main
  File "compose/cli/main.py", line 127, in perform_command
  File "compose/cli/main.py", line 1106, in up
  File "compose/cli/main.py", line 1102, in up
  File "compose/project.py", line 570, in up
  File "compose/parallel.py", line 112, in parallel_execute
  File "compose/parallel.py", line 210, in producer
  File "compose/project.py", line 556, in do
  File "compose/service.py", line 568, in execute_convergence_plan
  File "compose/service.py", line 510, in _execute_convergence_start
  File "compose/parallel.py", line 112, in parallel_execute
  File "compose/parallel.py", line 210, in producer
  File "compose/service.py", line 508, in <lambda>
  File "compose/service.py", line 620, in start_container_if_stopped
  File "compose/service.py", line 627, in start_container
TypeError: a bytes-like object is required, not 'str'
[85676] Failed to execute script docker-compose

?最近在一个新的服务器上装服务,没有安装iptables ,后来安装了iptables 之后,忽然发现我的docker 不能运行了。
??注意,可能别人的不行,我这个原因是,开始在新服务器上没有安装iptables ,先安装的docker ,后来才停用默认的firewall ,安装了iptables,就出现了这样的问题。其他原因,我不知道这方法可行不?先看错误:
??运行时报出了以下错误:

启动docker服务报错
Error response from daemon: No such container: yn-userservice-30000
26126ca87430b74c3987817492cc890e72c36e2fec10d807e362a12f22365160
/usr/bin/docker-current: Error response from daemon: driver failed programming external
connectivity on endpoint yn-userservice-30000 (5d083ef51f932ac24936713ab3bc1cece9d47feabf4a916cf5da12a4fb2a122a):
(iptables failed: iptables –wait -t nat -A DOCKER -p tcp -d 0/0 –dport 30000 -j DNAT –to-
destination 172.17.0.2:30000 ! -i docker0: iptables: No chain/target/match by that name.

后来在网上找了下,发现解决办法很简单,如下:

1、停止docker服务
??输入如下命令停止docker服务

systemctl stop docker 或者service docker stop
1
??停止成功的话,再输入docker ps 就会提示出下边的话:

Cannot connect to the Docker daemon. Is the docker daemon running on this host?
1
2、保存 iptables
??输入如下命令:

iptables-save > /etc/sysconfig/iptables
1
??我发现 防火墙的配置文件/etc/sysconfig/iptables前后文件如下,当然我是看不懂了,我也就会设置个入站端口
??保存之前文件内容:

sample configuration for iptables service

you can edit this manually or use system-config-firewall

please do not ask us to add additional ports/services to this default configuration

*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state –state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -p tcp -m state –state NEW -m tcp –dport 22 -j ACCEPT
-A INPUT -p tcp -m state –state NEW -m tcp –dport 80 -j ACCEPT
-A INPUT -p tcp -m state –state NEW -m tcp –dport 10001 -j ACCEPT
-A INPUT -p tcp -m state –state NEW -m tcp –dport 10002 -j ACCEPT
-A INPUT -p tcp -m state –state NEW -m tcp –dport 10003 -j ACCEPT
-A INPUT -p tcp -m state –state NEW -m tcp –dport 10004 -j ACCEPT
-A INPUT -j REJECT –reject-with icmp-host-prohibited
-A FORWARD -j REJECT –reject-with icmp-host-prohibited
COMMIT

??保存之后的文件内容:

Generated by iptables-save v1.4.21 on Sat Nov 24 13:53:13 2018

*nat
:PREROUTING ACCEPT [261:18558]
:INPUT ACCEPT [17:969]
:OUTPUT ACCEPT [4:304]
:POSTROUTING ACCEPT [4:304]
COMMIT

Completed on Sat Nov 24 13:53:13 2018

Generated by iptables-save v1.4.21 on Sat Nov 24 13:53:13 2018

*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [1246:135222]
-A INPUT -m state –state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -p tcp -m state –state NEW -m tcp –dport 22 -j ACCEPT
-A INPUT -p tcp -m state –state NEW -m tcp –dport 80 -j ACCEPT
-A INPUT -p tcp -m state –state NEW -m tcp –dport 10001 -j ACCEPT
-A INPUT -p tcp -m state –state NEW -m tcp –dport 10002 -j ACCEPT
-A INPUT -p tcp -m state –state NEW -m tcp –dport 10003 -j ACCEPT
-A INPUT -p tcp -m state –state NEW -m tcp –dport 10004 -j ACCEPT
-A INPUT -j REJECT –reject-with icmp-host-prohibited
-A FORWARD -j REJECT –reject-with icmp-host-prohibited
COMMIT

Completed on Sat Nov 24 13:53:13 2018

3、启动docker服务
??保存了iptables后,可以重新启动docker了。输入如下命令:

systemctl start docker 或者service docker start
1
4、将docker设置为开机启动
??设置过这个就不需要再设置了

systemctl enable docker
1
5、启动容器
??最后启动容器,发现不再报错了。

docker start 容器名字

文档更新时间: 2022-08-31 23:36   作者:阿力