Skip to content

Instantly share code, notes, and snippets.

@kyle-morton
Last active August 15, 2020 20:02
Show Gist options
  • Save kyle-morton/c1210af058822d6c6f3583acb6995807 to your computer and use it in GitHub Desktop.
Save kyle-morton/c1210af058822d6c6f3583acb6995807 to your computer and use it in GitHub Desktop.
Dockerfile Notes

Dockerfile

Dockerfiles represent a way to create an image w/ a layered file system using 1 or more existing images along w/ steps to build/copy files and dependencies.

Creating a customer ASP.NET Core Dockerfile

Easy way to autogenerate a production ready .dockerfile in VS Code -

  1. open project folder in vscode
  2. install both the docker & C# (omnisharp) extensions
  3. Ctrl+Shift+p => .NET: Generate Assets for build...
  • this will generate a .vscode folder w/ a launch.json and tasks.json for the build
  1. Ctrl+Shift+p => Docker: Add docker files to workspace... select .net core, windows, and what ports are exposed from the container (default is 80, 443). Note: "windows" only works if you're running windows containers in docker (need Windows 10 Pro)

Right-click the dockerfile in vscode and hit "build image..." to have it build the image on your machine for use in a container.

^ Use this method when possible to save time in generating docker file.

Debugging

  • Most issues w/ web apps in containers seem to be port driven when your starting out. Watch what ports your app is running on in the container vs the one it is bound to in the "docker build" command
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment