Git Product home page Git Product logo

learn-docker's Introduction

Docker

using docker version 24.0.7

To create dockerfile in your project then run the following command touch dockerfile

Or

Always use this command for best and recommanded practice is docker init . This command creates necessory files for docker.

Run the following command to build an docker image

docker build -t <name_of_your_image> .

Run the following command to run container docker run --name <your_container_name> -p <port_number_of_which_you_want_to_run_container>:<your_application_port> <your_image_name>

** Example :- docker run --name my-container -p 5055:5055 my-docker-image **

if you want to make versions of your container and image then run the below command

docker run --name <your_container_name> -p <port_number_of_which_you_want_to_run_container>:<your_application_port> <your_image_name>:v<version_number>

** Example :- docker run --name my-container -p 5055:5055 my-docker-image:v2 **

if you want to make versions of your container and image with volumes then run the below command

docker run --name <your_container_name> -p <port_number_of_which_you_want_to_run_container>:<your_application_port> --rm -v <absolute_path_of_your_current_dir>:<directory_you_have_specifed> <your_image_name>:v<version_number>

** Example :- docker run --name my-container -p 5055:5055 --rm -v D:\xampp\htdocs\learn-docker:/app my-docker-image:v2 **

Note :- The last dot means current directory. you can change current directory like this ../ or ../../ etc.

-t - flag is for naming you docker image.

-p - flag is for defining / exposing port numbers.

--name - flag is for naming you docker container.

--rm - flag is for removing containers and images.

-v - flag is for creating volums to sync changes.

.dockerignore - file use for ignore files and folders from docker project to docker image.

If you are using 0 port number means the docker container takes port number randomly.

To see all list of images in command line then run docker images

To see all list of containers in command line then run docker ps

use docker --help for more cli commands.

To delete docker unused image then run the following commnad docker image rm <your_image_name> .

To delete docker "In use" running... image forcefully then run the following commnad docker image rm <your_image_name> -f .

To delete docker unused container then run the following commnad docker container rm <your_image_name> .

To delete docker "In use" running... container forcefully then run the following commnad docker container rm <your_image_name> -f .

Use the docker container prune -a command to remove all stopped containers, or refer to the docker system prune -a command to remove unused containers in addition to other Docker resources, such as (unused) images and networks.

To Automate Docker Process you need to create compose.yaml file and define set of instructions.

after that you need to run the following command docker compose up

learn-docker's People

Contributors

gandharthakar avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.