Skip to main content

Docker (container, hub, image)

 Docker container

Docker hub

Docker Image - Docker hub (https://hub.docker.com/)where we can find docker images

===================================================================

                                                        Docker Commands:

===================================================================

1. docker pull imageName

    (docker pull imageName:version)    

2. docker run imageName (pulls image if not available and create container )

    (docker run -d imageName)  (detach mode)

   (docker run --name newName -d imageName) (to create name of container other than default name)

>docker run -e MYSQL_ROOT_PASSWORD=demo --name mySQLserverLatest mysql

Build a container from the image

    docker run -it imageName (-it for interactive mode)

3. docker images

4. docker ps -a   (to  check how many containers are running and their detail)

5. docker start

6.  docker stop

7. docker rmi imageId (or imageName) to remove image

8. docker rm containerId (remove container, first remover container and then image)


Port Binding: to bind port of  host to container  port  (-pHostPort:ContainerPort)

9. docker run -p8080:3306 imageName         









====================================================================

                                                                    Docker Network

=====================================================================

docker network ls

docker network create nameOfNetwork

docker network rm nameOfNetwork (to delete network)



=================================================================

Docker compose


manage multiple container

write container instruction in .yaml file

every individual container instruction comes under services

-- Docker Command 

above command in form of docker complose yaml file 






firt one is to run the docker compose with instruction in the filename.yaml

to remove docker compose (2nd command)

----------------------------------------------------------------------------------------------------------------------

Dockerizing of App

converting app to docker image and create container

FORM: base image 


dockerization of app using node and mongoDB





run below command for dockerization

--------------------------------------------------------



command to attach volume: (-v for volume and full path of source and container)

create ubuntu machine and attach local folder to container

docker run -v sourcePath:containerPath ubuntu 





docker volume created at path as below (if  no specific path is mentioned while creating volume)



Attaching volume to container/image



Comments

Popular posts from this blog

API Basics

 

Algorithm solving Common Patterns & Techniques

  These are targeted data manipulation strategies used to handle arrays, strings, and linked lists efficiently. Two Pointers : Uses two reference pointers to iterate through a data structure simultaneously, typically from opposite ends or at different speeds (Fast & Slow pointers). Sliding Window : Maintains a subset of data (a "window") over a sequential structure to track running statistics without recalculating the whole set. Prefix Sum : Pre-computes and stores cumulative sums of an array to allow for \(O(1)\) constant-time range sum queries. Dynamic Programming (DP ): Dynamic programming is an optimization technique used to solve problems by breaking them down into simpler subproblems and storing the results of these subproblems to avoid redundant computations. It is particularly effective for problems exhibiting overlapping subproblems and optimal substructure. Greedy Algorithm Breadth-First Search (BFS) / Depth-First Search (DFS) : Systematic graph and tree travers...