Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alpha951/dockerizing-basic-node-server
A basic project to learn about docker. This can be referred as tutorial to create a dockerize container from github
https://github.com/alpha951/dockerizing-basic-node-server
docker docker-container docker-image dockerfile
Last synced: 7 days ago
JSON representation
A basic project to learn about docker. This can be referred as tutorial to create a dockerize container from github
- Host: GitHub
- URL: https://github.com/alpha951/dockerizing-basic-node-server
- Owner: alpha951
- Created: 2023-09-10T08:57:22.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-09-10T09:12:43.000Z (over 1 year ago)
- Last Synced: 2023-09-10T10:20:56.174Z (over 1 year ago)
- Topics: docker, docker-container, docker-image, dockerfile
- Language: JavaScript
- Homepage:
- Size: 10.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Dockerfile to build a container image from this github repo
```dockerfile
FROM nodeWORKDIR /developer/nodejs/app_from_github
RUN apt-get update && apt-get install -y git
RUN git clone https://github.com/alpha951/dockerizing-basic-node-server.git .
RUN git pull origin main
ENV PORT=3000
RUN npm ci
CMD ["npm", "start"]
```## Build the image
```bash
docker build -t nodejs-app-from-github .
```
## Run the container
```bash
docker run -it --init --publish 5000:3000 app-from-github:latest
```
> The server will run at port 5000 in the host machine> EXPOSE 3000 also can be used to expose the port 3000 in the container to the host
## To bind the container with host directory
This command also make sure if there is any change in the project files inside the container then they will be reflected in the host machine. So it's a two way binding.
```bash
docker run -it --init --publish 5000:3000 -v "$(pwd)":developer/nodejs/app_from_github app-from-github:latest```
## Prune the docker system
```bash
docker system prune -a
```## Docker Volume
It's is used to persist the data in the container. It's a way to store the data in the host machine. So if the container is deleted then the data will be still there in the host machine.
Also if the container is binded with the host directory then the data will be stored in the host machine. So node_modules can create conflict while running in the container.
```bash
docker volume create node_modules_volume```
## Comunication between containers
```bash
docker network create microservice-network
```