A simple Node.js application in a Docker container.
Commands 👇
To create a Docker image for this application:
docker build -t dockify/back-end .docker build: This command builds an image from a Dockerfile.-t dockify/back-end: The-tflag tags the image with a name (dockify/back-end) for easy reference..: This specifies the current directory, where Docker will look for the Dockerfile.
To see all images currently available on your system:
docker images- This command displays a list of all Docker images along with details like Image ID, size, and creation date.
To start a container from the image you built:
docker run dockify/back-enddocker run: This command creates and starts a container from a specified image.dockify/back-end: Refers to the image name we created earlier.
Tip: To pass environment variables from a
.envfile when running the container, use:
docker run --env-file .env dockify/back-endThis loads environment variables defined in .env into the container.
To see all containers that are currently running:
docker ps- This command shows running containers along with details like Container ID, image, and status.
To stop a container, you can use either the container name or its ID:
docker stop <container_name_or_id>- Replace
<container_name_or_id>with the actual name or ID of the container fromdocker ps.
After stopping a container, you can remove it with:
docker rm <container_id>- Replace
<container_id>with the ID of the container you want to remove.
To delete an image from your system:
docker rmi <image_id>- Replace
<image_id>with the ID of the image you want to delete. You can get this ID fromdocker images.
| Command | Description |
|---|---|
docker build -t dockify/back-end . |
Build an image from the Dockerfile |
docker images |
List all Docker images |
docker run dockify/back-end |
Run a container from the image |
docker ps |
List all running containers |
docker stop <container_name_or_id> |
Stop a running container |
docker rm <container_id> |
Remove a stopped container |
docker rmi <image_id> |
Remove a Docker image |
docker run --env-file .env dockify/back-end |
Run container with environment variables from .env file |
This README should help you get started with Docker commands for this project!