Docker Commands
Docker Commands
2. Remove any Docker files that are running in the system, using the following command:
After entering the above command, you will need to enter the password of the root and press
enter.
You’ll then get a prompt asking you to choose between y/n - choose y
Pull an image from the Docker hub using the following command:
$ sudo docker ps -a
$ sudo docker ps
docker search -
docker pull –
Docker run -it -d name
docker ps -a
This command is used to show all the running and exited containers
docker exec
docker stop
This command kills the container by stopping its execution immediately. The difference between
‘docker kill’ and ‘docker stop’ is that ‘docker stop’ gives the container time to shutdown gracefully, in
situations when it is taking too much time for getting the container to stop, one can opt to kill it
To kill a container you must have a container running so first create a container.
BUILD AN IMAGE USING DOCKER
Step 2: Create an HTML application or use an existing template and Place your HTML files and
any other necessary assets (e.g., CSS, JavaScript, images) in the same project directory.
Step 3: Create a docker file and Copy Files to the Docker Image:
Add instructions in your Dockerfile to copy the HTML files into the Docker image. You can use the
COPY instruction. For example
Run the following command to build the Docker image, giving it a name and optional tag:
Step 5: Run the Docker Container:
Once the image is built, you can run a container from it using the following command:
Tag the Docker image to include your Docker Hub username and repository name. Replace
<username> and <repository> with your actual Docker Hub username and repository name:
Open a web browser and go to http://localhost:1002 (or the host and port you specified) to
access your HTML application running inside the Docker container.
If you're not already logged in to Docker Hub, use the docker login command to log in to your
Docker Hub account:
Step 8: Push the Docker Image to Docker Hub:
Now, push the Docker image to Docker Hub using the following command. Replace
<username> and <repository> with your actual Docker Hub username and repository name:
docker push <username>/<repository>