Eu tenho um contêiner docker em execução Ubuntu 18.04
.
Executei-o com o seguinte comando, mas se eu desligar uma interface, não importa o que eu faça, mesmo que diga que a interface está ativa, não consigo mais ter nenhuma conexão com ela.
docker run --hostname=hello.world --cap-add=NET_ADMIN -it test-ubuntu18
Dentro do meu contêiner, eu costumava ip link set eth0 down
desabilitar temporariamente a rede, mas depois de ligá-la novamente, nada funciona.
Este é o meu Dockerfile
FROM ubuntu:18.04 as base
# Install base dependencies
RUN apt-get update && apt-get install -y -q --no-install-recommends \
apt-transport-https build-essential ca-certificates curl dbus git \
iputils-ping libssl-dev net-tools network-manager vim wget systemd \
sudo rsyslog
ENV NVM_DIR /root/.nvm
ENV NODE_VERSION 17
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash \
&& . $NVM_DIR/nvm.sh \
&& nvm install $NODE_VERSION \
&& nvm alias default $NODE_VERSION \
&& nvm use default
# Fix rsyslog start up by disable imklog
RUN sed -i 's/module(load="imklog"/#module(load="imklog"/' /etc/rsyslog.conf
ENTRYPOINT service rsyslog start && \
service dbus start && \
service network-manager start && \
bash
Alguém sabe se é possível reativar a rede com um contêiner docker?
root@hello:~# ping google.com
PING google.com (172.217.13.110) 56(84) bytes of data.
64 bytes from 172.217.13.110 (172.217.13.110): icmp_seq=1 ttl=63 time=11.9 ms
64 bytes from 172.217.13.110 (172.217.13.110): icmp_seq=2 ttl=63 time=14.0 ms
^C
--- google.com ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1002ms
rtt min/avg/max/mdev = 11.982/13.011/14.041/1.035 ms
root@hello:~# ip link set eth0 down
root@hello:~# ping google.com
ping: google.com: Temporary failure in name resolution
root@hello:~# ip link set eth0 up
root@hello:~# ping google.com
ping: google.com: Temporary failure in name resolution
root@hello:~# ip link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
269: eth0@if270: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DEFAULT group default
link/ether 02:42:ac:11:00:02 brd ff:ff:ff:ff:ff:ff link-netnsid 0