title: How to use docker run with release docker compose build from Visual Studio 2017
body: <p>so, I'm learning and new to Docker and I'm trying to use the <code>docker run</code> command to run an image that is produced from Visual Studio 2017.</p>
  
  <p><strong>Some background:</strong></p>
  
  <p>The aim is to publish a docker image to a Container Registry (I'm using gitlab), create a docker droplet in DigitalOcean and pull the image and run it.</p>
  
  <p>I am trying to build a release image and run it locally first.</p>
  
  <p>I have a VS solution which contains 3 projects:</p>
  
  <ul>
  <li>.net core mvc</li>
  <li>.net core library</li>
  <li>.net core api </li>
  </ul>
  
  <p>I have a docker compose file and each project has a docker file. All generated by visual studio using the docker support tool.</p>
  
  <p>I can build and run both in debug and release mode in VS and it runs the image and I can browse to both the web app and api - all is okay.</p>
  
  <p>I have tried to follow the answer to this question: </p>
  
  <p><a href="https://stackoverflow.com/questions/43708578/how-to-run-docker-image-produced-by-vs-2017">How to run docker image produced by VS 2017</a></p>
  
  <p>So I have tried:</p>
  
  <p><code>docker run --rm -p 80:5000 -d myapp.web:latest</code></p>
  
  <p>And I have tried both <code>http://localhost:5000</code> and <code>http://127.0.0.1:5000</code> in a browser and both cannot be loaded or resolved.</p>
  
  <p>I can see the docker images produced by VS below via the <code>docker images</code> command</p>
  
  <pre><code>REPOSITORY                   TAG                 IMAGE ID            CREATED             SIZE
  myapp.apinet                 latest              b3fa6d92bd23        24 hours ago        305MB
  myapp.web                    latest              f418d4571ac3        24 hours ago        315MB
  &lt;none&gt;                       &lt;none&gt;              50c89857daf1        24 hours ago        315MB
  </code></pre>
  
  <p>If it helps, one of my docker files:</p>
  
  <pre><code>FROM microsoft/aspnetcore:2.0 AS base
  WORKDIR /app
  EXPOSE 80
  
  FROM microsoft/aspnetcore-build:2.0 AS build
  WORKDIR /src
  COPY *.sln ./
  COPY src/myapp.Web/myapp.Web.csproj src/myapp.Web/
  COPY src/myapp.Core/myapp.Core.csproj src/myapp.Core/
  RUN dotnet restore
  COPY . .
  WORKDIR /src/src/myapp.Web
  RUN dotnet build -c Release -o /app
  
  FROM build AS publish
  RUN dotnet publish -c Release -o /app
  
  FROM base AS final
  WORKDIR /app
  COPY --from=publish /app .
  ENTRYPOINT ["dotnet", "myapp.Web.dll"]
  </code></pre>
  
  <p>I have also inspected the docker image using <code>docker inspect myapp.web</code> and port 80 is exposed:</p>
  
  <pre><code>"ExposedPorts": {   
  "80/tcp": {}    
  },                  
  </code></pre>
  
  <p>I have tried the asp.net core example from <a href="https://github.com/dotnet/dotnet-docker/tree/master/samples/aspnetapp" rel="nofollow noreferrer">https://github.com/dotnet/dotnet-docker/tree/master/samples/aspnetapp</a> as below, and that works fine.</p>
  
  <p><code>docker run --rm -p 8000:80 --name aspnetcore_sample microsoft/dotnet-samples:aspnetapp</code></p>
  
  <p>Any suggestions or ideas?</p>