- Docker Engine installation guide - https://docs.docker.com/engine/install/ubuntu/
- !# Create and add admin docker user to docker group, add permissions
- useradd -m -s /bin/bash username
- usermod -aG docker username
- passwd username
- sudo usermod -aG sudo username
- id username
- su - username
- docker --version
- docker ps
- docker ps -a
- docker rm # remove container
- docker rmi # remove image
- docker images
- docker run -d -p 80:80 docker/getting-started
- service docker status
- docker stop # stop container
- docker start # start exiting container
- docker run ubuntu:20.04 ls
- docker run -d --rm --name My-Container ubuntu:20.04 echo "Hello my docker!"
- docker logs -f # live container logs
- docker system prune -a --volumes # remove all images and containers
- docker exec -it web1 /bin/bash # enter into container interactive
- docker run -d --name web1 -p 80:80 nginx
- cd /usr/share/nginx/html/
- echo "Web server 1" > test.html
- docker run -d --name web2 -p 8080:80 nginx
-
docker run --name some-mysql -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql:tag
-
docker exec -it DB-mysql /bin/bash
-
env # display details of mysql
-
docker exec -it DB-mysql mysql -uroot -p # enter into mysql in container
-
docker run --name DB-mysql2 -e MYSQL_ROOT_PASSWORD=pw1234 -e MY_VARS=1233456 -d mysql
- docker run --name web01 -p 80:80 -d nginx
- ip a
- cd /opt/
- mkdir nginx
- cd nginx
- mkdir data
- docker run --name web02 -p 80:80 -v /opt/nginx/data:/usr/share/nginx/html -d nginx # Host volume
- docker run --name web02 -p 80:80 -v /usr/share/nginx/html -d nginx # Annonymus volume /var/lib/docker/volumes
- docker run --name web02 -p 80:80 -v /my_volume:/usr/share/nginx/html -d nginx # Named volume /var/lib/docker/volumes
- docker volume ls
- docker volume create infos
- docker volume rm infos
- docker network ls
- docker network create myNet01
- docker run --rm -it --name container1 nicolaka/netshoot /bin/bash
- docker run --rm -it --name container2 nicolaka/netshoot /bin/bash
- docker inspect container1
- docker run --rm -it --name container1 --net myNet01 nicolaka/netshoot /bin/bash
- docker run --rm -it --name container2 --net myNet01 nicolaka/netshoot /bin/bash
- docker network connect myNet01 container2
- docker network disconnect container2
- docker network create myNet02
- docker run --rm -it --name container1 --net myNet02 nicolaka/netshoot /bin/bash # Named Networks
- docker run --rm -it --name container1 --net host nicolaka/netshoot /bin/bash
- docker run --rm -it --name container2 --net host nicolaka/netshoot /bin/bash # Host IP
- docker run --rm -it --name container1 --net none nicolaka/netshoot /bin/bash # No IP
- docker network create -d macvlan --subnet 192.168.100.0/24 --gateway 192.168.100.1 --ip-range 192.168.100.99/32 -o parent=eth0 myMACvlan32 # creating macvlan
- docker run --rm -it --name container1 --net myMACvlan32 nicolaka/netshoot /bin/bash # macvlan
- docker network create -d macvlan --subnet 172.31.24.0/24 --gateway 172.31.24.1 --ip-range 172.31.24.207/32 -o parent=eth0 MyHomeLan
- FROM ubuntu:22.04
- LABEL autor=Burmetskyi
- RUN apt-get update
- RUN apt-get install nginx -y
- WORKDIR /var/www/html/
- COPY files2/index.html
- COPY files2/script.sh /opt/script.sh
- RUN chmod +x /opt/script.sh
- ENV OWNER="Burmetskyi"
- ENV TYPE=demo
- EXPOSE 80
- ENTRYPOINT ["echo"]
- CMD ["Hello my FIRST Docker"]
- docker build
- docker tag name:version
- docker run --rm --name mydocker mydocker:v01
- docker image inspect mydocker:v01
- netstat -tulpe
- FROM ubuntu:22.04
- LABEL autor=Burmetskyi
- RUN apt-get update
- RUN apt-get install nginx -y
- EXPOSE 80
- EXPOSE 443/tcp CMD ["nginx","-g","daemon off"]
-
FROM ubuntu:22.04
-
LABEL autor=Burmetskyi
-
RUN apt-get update
-
RUN apt-get install apache2 -y
-
EXPOSE 80
-
CMD ["apache2ctl","-D","FOREGROUND"]
-
docker run -d --rm --name d1 -p 80:80 -v <absolute/path>:/var/www/html mynginx:01
- docker run -d --rm --name d2 -e TYPE=prod mynginx:05
FROM ubuntu:22.04
-
LABEL autor=Burmetskyi
-
RUN apt-get update
-
RUN apt-get install apache2 -y
-
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
-
WORKDIR /var/www/html
-
COPY files/index.html .
-
ENV OWNER=Burmetskyi
-
ENV TYPE=demo
-
EXPOSE 80
-
CMD ["apache2ctl","-D","FOREGROUND"]
-
docker run --rm --name d1 -it -e OWNER=Billie myenv:01 /bin/bash
-
#!/bin/bash
-
sed -i 's|%OWNER%|'"$OWNER"'|g' /var/www/html/index.html
-
sed -i 's|%TYPE%|'"$TYPE"'|g' /var/www/html/index.html
-
echo "Start Script --- OK"
-
nginx -g 'daemon off;'
- FROM ubuntu:22.04
- LABEL author=Burmetskyi
- RUN apt-get update
- RUN apt-get install nginx -y
- RUN apt-get clean && rm -rf /var/lib/apt/lists/*
- WORKDIR /var/www/html
- COPY files/index.html .
- COPY files/script.sh /opt/script.sh
- RUN chmod +x /opt/script.sh
- ENV OWNER=Burmetwkyi
- ENV TYPE=demo
- EXPOSE 80
- CMD ["/opt/script.sh"]
-
phpinfo();
-
phpinfo(INFO_MODULES);
-
?>
-
FROM php:7.2-apache
-
COPY index.php /var/www/html/
-
num1 = input('Enter first number: ')
-
num2 = input('Enter second number: ')
-
sum = float(num1) + float(num2)
-
print('The sum of {0} and {1} is {2}'.format(num1, num2, sum))
-
FROM python:3
-
WORKDIR /usr/src/app
-
COPY sum.py ./
-
CMD [ "python", "./sum.py" ]
- Install Docker Compose: https://docs.docker.com/compose/install/linux/
- docker compose up
- docker compose logs -f
- docker compose stop
- docker compose down
- how to install Portainer: https://docs.portainer.io/start/install-ce/server/docker/linux
- docker run --rm -v ${PWD}:/myvol ubuntu /bin/bash -c "ls -lha > /myvol/myfile.txt"