Created
July 5, 2021 22:53
-
-
Save cyberbiosecurity/88b29f41949b620299b9809316c42c4d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
##################################################################### | |
####### !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!####### | |
####### Use DOUBLE QUOTES in CMD line in Dockerfile! ####### | |
####### !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!####### | |
##################################################################### | |
sudo apt install apt-transport-https | |
#Нужная штука? | |
sudo systemctl status docker | |
sudo docker ps | |
#IF PERMISSION DENIED: | |
sudo usermod -aG docker $USER | |
#then | |
exit | |
docker images | |
docker run hello-world | |
docker images | |
docker search centos | |
docker pull centos:centos7 | |
docker images | |
#check IP of host | |
ipconfig | |
#show ALL containers, including previously running containers. | |
docker ps -a | |
#run interactively, access container's port 8080 via 1234 port from outside. | |
docker run -it -p 1234:8080 centos:centos7 | |
docker run -it -p 1234:8080 tomcat | |
#run as daemon | |
docker run -d -p 1234:8080 tomcat | |
#nginx | |
docker run -d -p 1237:8080 nginx | |
#remove images | |
#Won't work if image is used by running container | |
docker rmi tomcat | |
#remove container (not running, but blocking the removal of its image) | |
#(using container's ID) | |
docker rm 0efa14bd | |
#NOW TO DOCKERFILE_2 | |
nano DOCKERFILE | |
# create dockerfile in current dir, then: | |
# dot means "HERE" (current dir) | |
docker build -t vadim-centos-python-http:v1 . | |
#check | |
docker images | |
docker run -d -p 8080:80 vadim-centos-python-http:v1 | |
#create duplicate image with new tag | |
docker tag vadim-centos-python-http:v1 vadim-centos-python-http:copy | |
#LOGIN TO RUNNING DOCKER CONTAINER | |
# 0b8a3cccae12 is some RUNNING container! | |
# We login into it and run /bin/bash. | |
docker exec -it 0b8a3cccae12 /bin/bash | |
#Now we are in the internal container shell. | |
nano index.html | |
#inside container! | |
#make some changes inside container, then: | |
exit | |
#now we'va left running container's shell. | |
#Now let's make new image from modified container. | |
#0b8a3cccae12 - our running container with modified contents. | |
# We will create new image: vadim-centos-python-http:v2 | |
docker commit 0b8a3cccae12 vadim-centos-python-http:v2 | |
#check | |
docker images | |
docker run -d -p 8080:8888 vadim-centos-python-http:v2 | |
#new container ID is 6abc3bef10 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment