Remove all dangling images (it occurs when building a new image and giving it a tag that already exists)
Remove all unused images
Search Images
Show environment variables
Expose ports
Check logs
Enter into the container
Run container and enter dash
Check processes in a container
Check using space
docker search
only official repos
docker search
check details about an images
Dockerfile
The difference between copy and add?
In a Dockerfile, the COPY instruction copies files from the build context into the container, while ADD does the same thing but also has some extra features such as the ability to download files and extract tar files. In general, it is recommended to use COPY for copying files, since it is simpler and less prone to unexpected behavior.
Â
Java
Node.js
Build the image
Run the image
Docker container status can have the following values:
created: The container has been created, but it has not been started yet.
restarting: The container is currently restarting.
running: The container is currently running.
paused: The container has been paused.
exited: The container has stopped running.
dead: The container is no longer running and cannot be restarted.
These statuses can be viewed using the docker ps -a command, which will display a list of all containers and their statuses.
Â
Example
Example 1
The Dockerfile has three distinct build stages. Stage 0 is called storefront, stage 1 is called appserver, and stage 2 is called production. Each stage pulls a different image and performs various tasks. An important thing to note is that COPY --from instructions are used to only copy production-related application code from the images built by the previous stages. They do not copy build artifacts that are not needed for production.
Example 2
To create a setup with a Node.js app and Nginx as a load balancer using Docker, you will need two separate Dockerfiles and a docker-compose.yml file to orchestrate the containers. We'll create a simple Node.js app first, then write Dockerfiles for both the app and Nginx, and finally, create the docker-compose.yml file.
Create a simple Node.js app:
Create a new directory for your app, and inside that directory, create the following files:
Create a Dockerfile for the Node.js app:
In the same directory, create a file named Dockerfile for the Node.js app:
Create a Dockerfile for Nginx:
Create a new directory for Nginx, and inside that directory, create a file named Dockerfile for Nginx:
Create an Nginx configuration file:
In the Nginx directory, create a file named nginx.conf:
Create a docker-compose.yml file:
In the root directory, create a docker-compose.yml file: