docker ( double tab )
Help command
docker volume help
docker image help
docker info
- docker system information will be displayed.
- Above highlighted option will be ENABLED when we use CLUSTER in docker.
docker system df
- All images & containers will be displayed.
Docker real-time Events or logs
docker system events
docker system prune
- It deletes all image and container.
- Its a risky command as it removes unused data & free size.
help or man
man docker system
or
docker system help
docker stats
- Usage details are shown here.
docker search busapp
- this search command , will get all the application i.e busapp installed in public repository of docker.
docker images
- List the images which are present in the system.
Pulling the image from HUB
- why am I pulling the image ? To launch a container I need an image.
docker pull httpd
docker images
docker pull alpine
Where these images stored ?
- It will be occupying your disc.
- Check it with df command.
docker system df
How to run a IMAGE ?
- There are two things , one is create & run
- CREATE --> Create the container but not in running state.
- RUN --> Create the container & run the container too.
docker run --name testing_web httpd
docker ps
--name --> Name for the container
httpd --> name of the image
- But the above one is running in foreground , so you can't perform anything in that window . But the container will come up.
- CONTROL + C ( now the container will not be available )
RUN the container in back-ground
docker run -d --name testing_web httpd
docker ps -a ( shows all the container running & stopped )
d --> for demonize which runs in back-ground
- Running the same command will end up in error because as we are using the same container name . Even though we stopped but the container is still there. IN other words " Its stopped but still the container is available in that name.
- Provide a NEW NAME to the container.
docker run -d --name testing_web_new httpd
docker ps
Lets login to the CONTAINER
docker exec -it testing_web /bin/sh
docker exec -it testing_web /bin/bash
testing_web --> container name
/bin/sh --> shell type , we ca use bash also.
it --> Interactive terminal
Here the trick is that , NOT all commands we can run inside this container . Check it. Also we are not aware what OS they used to build the image.
- It will only files which are related to httpd only.
- only these commands can be used inside the container.
Without logging in Can we execute COMMANDS ?
- YES
- Remove the 'it' from the command.
docker exec testing_web_new uname -a
docker exec testing_web_new hostname
docker exec testing_web_new mkdir /tmp/testing_dir
Copy FILES from local to CONTAINER
docker cp <file_name_local> <container_id/conatiner_name>:<destination>
docker ps
docker cp local_file 6438c81d6841:/tmp
docker exec testing_web_new ls /tmp
docker cp local_file testing_web_new:/tmp
Copy FILES from CONTAINER to Local
docker cp <file_name_local> <container_id/conatiner_name>:<destination>
touch local_to_container
docker ps
docker cp local_to_container 4b:/tmp
docker exec os_service_3 ls /tmp
rm local_to_container
docker cp 4b:/tmp/local_to_container .
Note : 4b --> Nothing but start of the container. You can give in this WAY.
How to START & STOP the CONTAINER?
docker ps -a
docker stop testing_web_new
docker ps -a
docker start testing_web_new
docker start testing_web
System related check for these containers
docker system df
docker stats
docker stats <container_name>
docker top <container_name>
How to remove the CONTAINER ?
- Keep in Mind " You cant remove a RUNNING Container ". But we can with FORCE option.
- Before remove , STOP the container. ( safest way )
docker ps
docker rm testing_web_new
docker rm -f testing_web_new
docker ps
docker stop testing_web
docker rm testing_web
docker ps
docker logs
- By giving the container Name , we can check the logs.
- Start logs only visible.
- LETS start the alpine and check the logs.
- Above screen shows Alpine is started but its not running.
- Alpine is just a OS , so we need to provide what type of bash is required.
docker run -d --name os_service_2 alpine /bin/sh --> NOT WORKING / ERROR
docker run -d --name os_service_1 alpine /bin/sh --> NOT WORKING / ERROR
docker run -d -it --name os_service_3 alpine /bin/sh
System Prune
- Clear the container.
docker system prune
- EXITED all got deleted.
Reference :
[ TO BE CONTINUED ]
Top comments (0)