<p>I have an application that uses a MAC Address for licensing. I'd like to run this application in a docker container for CI/CD purposes. I created a docker container and use the <code>ENTRYPOINT</code> to run a shell script. The issue I am running into now is that when I try to ping any server I get network errors. I am wondering if this is something that I can fix or if I am doing this incorrectly. I'd love to find a solution for this so I can test scripts that I write for this system before pushing them to production. I'll be around to answer any additional questions.</p>
<p><strong>Dockerfile</strong></p>
<pre><code>FROM centos:latest
COPY startup.sh /startup.sh
ENTRYPOINT [&quot;/bin/sh&quot;, &quot;/startup.sh&quot;]
</code></pre>
<p><strong>startup.sh</strong></p>
<pre><code>ip link set dev eth0 down;
ip link set dev eth0 address 02:42:ac:11:00:11;
ip link set dev eth0 up;
</code></pre>
<p><strong>Errors</strong></p>
<pre><code>sh-4.4# ip link
1: lo: &lt;LOOPBACK,UP,LOWER_UP&gt; 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
2: sit0@NONE: &lt;NOARP&gt; mtu 1480 qdisc noop state DOWN mode DEFAULT group default qlen 1000
    link/sit 0.0.0.0 brd 0.0.0.0
29: eth0@if30: &lt;BROADCAST,MULTICAST,UP,LOWER_UP&gt; mtu 1500 qdisc noqueue state UP mode DEFAULT group default
    link/ether 02:42:ac:11:00:11 brd ff:ff:ff:ff:ff:ff link-netnsid 0

sh-4.4# ping google.com
ping: google.com: Name or service not known

sh-4.4# ping 4.4.4.4
connect: Network is unreachable
</code></pre>

IdecEddy
<p>If you need to override low-level networking details like this, you should generally do it at the Docker level.  For example, there is a <a href="https://docs.docker.com/engine/reference/run/#network-settings" rel="nofollow noreferrer"><code>docker run --mac-address</code> option</a> that you can specify when you launch the container.  You shouldn't need to run <code>ip</code>, <code>ifconfig</code>, or similar network-management commands in your container's startup sequence; this is entirely handled by Docker.</p>
<pre class="lang-sh prettyprint-override"><code>docker run --mac-address 02:42:ac:11:00:11 ...
</code></pre>
