Docker - 2
basic commands in docker
------------------------
login to docker (docker login)
-> to see all images present in your local machine.
docker images
-> to find out images in docker hub
docker search jenkins (first logout from docker)
-> to download image from dockerhub to local machine
docker pull jenkins
-> to give name to container
docker run -it --name bhupinder ubuntu /bin/bash (i- interactive mode and t - terminal )
-> to check service is start or not
serice docker status
->to start container
docker start bhupinder
-> to go inside container
docker attach bhupinder
->to see all containers
docker ps -a
-> to see only running containers
docker ps
-> to stop container
docker stop bhupinder
--> to delete container
docker rm bhupinder
how to install docker on linux machine
yum update -y
yum install docker -y
which docker
docker -v
docker --version
service docker status
docker info
service docker start
service docker status
docker info
docker images
docker run -it --name bhupinder ubuntu /bin/bash
cat /etc/os-release(run inside the container)
# docker exec -it -u root 7554a5ebe943 /bin/bash
root@server:/usr/local/apache2# cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 10 (buster)"
NAME="Debian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
root@server:/usr/local/apache2# exit
exit
question
if we start the container then we go inside it and when we do exit it gets stop. how to make it run even if we exit from it.?
docker attach --detach-keys="ctrl-a" new
if you press ctrl a then you will exit the container without stopping it
Comments
Post a Comment