DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations

Trending

  • Managing AI-Powered Java App With API Management
  • Build a Serverless Application for Audio-To-Text Conversion
  • Scalability Testing Tutorial: A Comprehensive Guide With Examples and Best Practices
  • Resolve Encoding Issues of Resource Files in Java Projects

Trending

  • Managing AI-Powered Java App With API Management
  • Build a Serverless Application for Audio-To-Text Conversion
  • Scalability Testing Tutorial: A Comprehensive Guide With Examples and Best Practices
  • Resolve Encoding Issues of Resource Files in Java Projects
  1. DZone
  2. Data Engineering
  3. AI/ML
  4. How to Run a Docker Container on Your Local Machine

How to Run a Docker Container on Your Local Machine

This quick walkthrough will show you how to dockerize and run an Angular2 app in a container on your local machine, with frequently used Docker commands.

Suleyman Yildirim user avatar by
Suleyman Yildirim
·
Sep. 04, 17 · Tutorial
Like (4)
Save
Tweet
Share
138.39K Views

Join the DZone community and get the full member experience.

Join For Free

i have been working on a hobby project, nutrition tracking app, to practice the latest continuous integration tools. this post is about dockerizing an angular2 app and on your local machine. i skipped the basic definitions about docker, containers, and ci for the sake of simplicity.

docker commands

frequently used docker commands:

build docker image

docker build -t image-name .

run docker image

docker run -p 80:80 -it image-name

stop all docker containers

docker stop $(docker ps -a -q)

remove all docker containers

docker rm $(docker ps -a -q)

remove all docker images

docker rmi $(docker images -q)

port bindings of a specific container

docker inspect [container-id]

dockerfile

a dockerfile is a text document that contains all the commands a user could call on the command line to assemble an image. here's a simple dockerfile that copies the "dist" folder to /usr/share/nginx/html:

from nginx
copy dist /usr/share/nginx/html
expose 80

project structure

the dockerfile should be located in the root of the project. here is an example from my project:

how to run the docker container on your local machine

build

docker build -t angular-webpack .

run

docker run -p 9000:80 -t angular-webpack

this will create a container with the image "angular-webpack" and bind the container’s port 80 to the host machine’s port 9000. after the "docker run -p 9000:80 -it angular-webpack" command, the docker container runs on a linux virtual machine. so we can't run docker natively on windows or a mac. the following properties must be set:

set environment properties

set userprofile = c:\users\xxx  --> set your user proile 

set docker_cert_path=%userprofile%\.docker\machine\machines\default

set docker_host=tcp://192.168.99.100 --> find this ip in docker quick start terminal

set docker_machine_name=default

set docker_tls_verify=1

test: http://192.168.99.100:9000/index.html

for troubleshooting: https://stackoverflow.com/questions/41208782/docker-localhost-process-not-working-on-windows .

Docker (software) Machine

Opinions expressed by DZone contributors are their own.

Trending

  • Managing AI-Powered Java App With API Management
  • Build a Serverless Application for Audio-To-Text Conversion
  • Scalability Testing Tutorial: A Comprehensive Guide With Examples and Best Practices
  • Resolve Encoding Issues of Resource Files in Java Projects

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com

Let's be friends: