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 imagedockerization 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
Comments
Post a Comment