Dockerfile vs docker run
<p>I am having a problem with published ports in Docker using Dockerfile compared to using docker run manually. Using the following command, the Docker container starts successfully, and when I visit the Host IP address (192.168.99.100) in the browser with <a href="http://192.168.99.100:8080" rel="nofollow">http://192.168.99.100:8080</a> – the RabbitMQ Web Management Dashboard loads.</p>

<pre><code>docker run -d --hostname my-rabbit --name some-rabbit -p 8080:15672 rabbitmq:3.5.6-management
</code></pre>

<p>At this point, I run the following to free up the ports I want to use from the Dockerfile:</p>

<pre><code>docker stop some-rabbit
</code></pre>

<p>When I run the following docker-compose commands, once I visit the same URL above (<a href="http://192.168.99.100:8080" rel="nofollow">http://192.168.99.100:8080</a>) I receive "This site can’t be reached 192.168.99.100 refused to connect."</p>

<pre><code>docker-compose build
docker-compose up -d
</code></pre>

<p>Here is the Dockerfile I am using:</p>

<pre><code>version: '2'
services:
    rabbitmq:
        container_name: rabbit
        hostname: rabbit
        ports:
            - "8080:15762"
        image: rabbitmq:3.5.6-management
</code></pre>

<p>Below is the result of <code>docker ps</code> after <code>docker run</code></p>

<pre><code>6c5a97bd51bc rabbitmq:3.5.6-management "/docker-entrypoint.s" 16 seconds ago Up 15 seconds 4369/tcp, 5671-5672/tcp, 15671/tcp, 25672/tcp, 0.0.0.0:8080-&gt;15672/tcp some-rabbit
</code></pre>

<p>Below is the result of <code>docker ps</code> after <code>docker-compose up -d</code></p>

<pre><code>99987aeb5cbf rabbitmq:3.5.6-management "/docker-entrypoint.s" 13 seconds ago Up 11 seconds 4369/tcp, 5671-5672/tcp, 15671-15672/tcp, 25672/tcp, 0.0.0.0:8080-&gt;15762/tcp rabbitmq
</code></pre>