forked from bregman-arie/devops-exercises
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a couple of questions on containers
Also, fixed some minor styling issues in random_question.py script.
- Loading branch information
abregman
committed
Oct 24, 2021
1 parent
aa420a7
commit 51ecb4f
Showing
5 changed files
with
113 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
## Containerize an Application | ||
|
||
1. Clone an open source project you would like to containerize. A couple of suggestions: | ||
|
||
``` | ||
https://github.com/bregman-arie/node-hello-world | ||
https://github.com/bregman-arie/flask-hello-world | ||
``` | ||
|
||
`git clone https://github.com/bregman-arie/node-hello-world` | ||
|
||
2. Write a Dockerfile you'll use for building an image of the application (you can use any base image you would like) | ||
|
||
``` | ||
FROM alpine | ||
LABEL maintainer="your name/email" | ||
RUN apk add --update nodejs npm | ||
COPY . /src | ||
WORKDIR /src | ||
RUN npm install | ||
EXPOSE 3000 | ||
ENTRYPOINT ["node", "./app.js"] | ||
``` | ||
|
||
3. Build an image using the Dockerfile you've just wrote | ||
|
||
`docker image build -t web_app:latest .` | ||
|
||
4. Verify the image exists | ||
|
||
`docker image ls` | ||
|
||
5. [Optional] Push the image you've just built to a registry | ||
|
||
``` | ||
docker login | ||
docker image tag web_app:latest <your username>/web_app:latest | ||
# Verify with "docker image ls" | ||
docker image push <your username>/web_app:latest | ||
``` | ||
|
||
6. Run the application | ||
|
||
``` | ||
docker container run -d -p 80:3000 web_app:latest | ||
``` | ||
|
||
7. Verify the app is running | ||
|
||
``` | ||
docker container ls | ||
docker logs <container ID/name> | ||
# In the browser, go to 127.0.0.1:80 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters