Docker Installation and Commands
Docker Installation and Commands
Docker –version
Docker version
Docker images
Docker search images its shows all related latest/old version ubuntu OS details
Docker pull ubuntu/windows/Jenkins
Once command execute then automatically ubuntu image bas been created in local area.
7. Once done the image, then you can do it container with image it means we are creating a
ubuntu OS.
8. For logging into/accessing the container, one uses the exec command or Run command
9. Can stop the container/kill/rm (remove the container) the container.
DOCKER HUB
MKDIR app it means apps directory created in that container OS and whenever
exit from container automatically apps directory will be deleted.
Whenever trying to delete the image it won’t accept why bcoz image container
already running state.
In some cases, we can delete with help command (docker rm -f image
id(xxxxxxx))
Once delete container it means all data will be deleted in that container images
OS. Again once login into the same OS it wont have the same directory in that
container OS it means fresh OS will be running. If you saw below image APP dir
not available.
For this scenario docker need to save container with name <>
This how create a custom container and save with name.
One more useful command is docker rm -f $(sudo docker ps -a -q) this will clear all containers.
Install the Apache server on this container.
Now we are updating the software’s in container image ubuntu OS
Once service up and running. need to exit from the container and save the name with proper
naming standards. Like userid/name of container.
For verification whether Apache server working or not.
Now we are created a Dockerfile and html file after that we need to build docker file.
Before build, we need to know how to run the Dockerfiles in user mod.
Once app image done, you may verify whether image create or not with help command.
Docker Image
Once image created, then you can run the image and map the port value.
Docker run -it -p 84:80 -d new_dockerfile<filename> once ran the command it will launch the
container.
If you want, see what container having the files. For that we need to run the below command.
Once done we can also push new_dockerfile into docker hub repository.
To persist data across the lifetime of a container and to accomplish there are two ways.
1. Bind mount.
2. Docker volumes.
Bind mount: To map directory inside of local machine/container and it will be mirroring same files
which is mapped directory.
And if go back to Dockerfile folder and create a any file, and then same will be mirroring to container
APP folder.
1. If the file structure won’t change, then the bind mount concept it will work.
2. If any reason, the file structure/file path has been changed/ and it won’t work in different
environment like windows/ other like favours then it won’t work the bind mount concept.
This case or to overcome, we are going to prefer the docker volumes.
Created one container like ubuntu and mount with docket volume <Volume name as TEST>
And again, I created one more container and mount with docker volume as TEST.
And here, wherever do perform the validation and same data will in both containers why bcoz of
both containers mount on same page.
Need to install docker compose and its not a build package in linux.
Need to get from outside.
docker-compose --version
Create a yaml file with proper standard rules
Once ran the docker-compose file, Mysql and database up and running
Here we need to create a master and worker node.
Once ran it will be automatically created connectivity between the master and
worker.
1. if you want left/ leave then you can run the docker swarm leave in worker
node
2. Master node if you want to leave then run the command as docker
swarm leave –force
Once connection established between master and worker with help of
swarm/service.
And Apache app always running in both side like worker and master with port
83.
Master node/session:
Worker node/session:
I can scale up or down COMMAD with of docker service scale aapache.
Docker service scale apache=2 or 10