Welcome to another post about Docker! If you need help with the installation please refer to my other post titled Docker Installation on a MacOS Laptop.
Why Docker is Powerful?
Docker is an open platform application for developing, running, and shipping off applications through containers. Docker is powerful because it takes a larger application and breaks it down into smaller more chuckable pieces aka services. Microservices are a cloud based approach where a single application is made up of different working smaller services. Below is an image that shows some structure. Everyone can communicate in one single place. Each of the services can be considered a microcomputer. Some known companies that are notable which use Docker are Spotify, Yelp, and Uber to name a few.
How to get Started with Play with Docker
Go to Docker Playground to start to play with Docker. After you will be able to start to add a new instance. From there, you are able to access your own server to run Docker. To start to see this come to light, you can start an instance to run an application. A Dockerfile describes how the actual container is built. A snippet that shows this is...
FROM node:10-alpine
WORKDIR /app
COPY . .
RUN yarn install --production
CMD ["node", "/app/src/index.js"]
EXPOSE 3000
To build a container, run docker build -t todoapp .
Then you can look at images, docker images
and then run a container docker run -d -p 3000:3000 todoapp
and multiple ones
docker run -d -p 3001:3000 todoapp
docker run -d -p 3002:3000 todoapp
docker run -d -p 3003:3000 todoapp
Screenshots of the NewsAPI Microservice
Below shows the success of a web component communicating with a backend microservice and the newsapi.org.
SUCCESS!
How to Create a DockerFile for Repo
- Find the GitHub Repo and run it on Docker Playground
- Run
touch Dockerfile
- Select the editor to open and see the file.
- Click on Dockerfile (double click) and enter...
# syntax=docker/dockerfile:1
FROM node:12-alpine
RUN apk add --no-cache python2 g++ make
WORKDIR /app
COPY . .
RUN yarn install --production
CMD ["node", "src/index.js"]
- Run
docker build -t getting-started .
- Run
docker run -dp 3000:3000 getting-started
to start. - When open it, should be running locally on the port.
Bonus Feature: Image below shows using touch
the created Dockerfile for Nasa Image Search!!!!!
Top comments (0)