Docker
1. docker image pull virtualpairprogrammers/fleetman-webapp. Bu komanda docker hub-dan image docker-e yukleyir.
2. docker container run {image name}: docker container run virtualpairprogrammers/fleetman-webapp. Bu komanda image-i run etmek ucundur.
3. docker container run -p 8080:8080 virtualpairpogrammers/fleetman-webapp. -p komandasi xarici port vermak ucun istifade olunur, yeni xarici portu dockerin icindeki porta birlewdirir.
4. docker container run -p 8080:8080 -d virtualpairpogrammers/fleetman-webapp: -d burada container-i detacht modda caliwdirir, yeni arxa modda ozu caliwacaq. -d komandasini run komandasindan sonrada vere bilerik.
5. docker container ls veya docker container ps veya docker ps: bu komanda butun run olan yeni ayaqda olan container-leri gosterir
6. docker ps -a veya docker container ls -a: bu komanda iwleyen ve iwlemeyen butun container-leri gosterir.
7. docker container stop {container id}: docker container stop 9d6263cc69a0. Bu komanda run oland container-i dayandirir.
8. docker container run -it ubuntu: Bu komanda interactive run edir. i - interactive t - terminal demekdir.
9. docker container rm {container id}: bu komanda containeri silir.
10. docker container prune: butun container-leri silir.
11. docker container logs {container id}: containerin loglarina baxmaq ucundur
12. docker container exec -it {container id} bash: container-in interaktiv bash-ini acir. (interactive terminal)
13. exit: hemin bash shell-den cixir.
14. docker container commit -a "Parvin Etibarli etibarliparvin@gmail.com" {container id} myjdkimage: bu komanda yeni image yaradir. Bu bildiyim qederi ile rahatciliq ucun edilir
-----------------------------------------------------------------------------------------------------------------------------
1. docker rmi $(docker images -aq): butun imageleri silir
2. docker rm -f $(docker ps -aq):
3. docker run --name ms9-mysql mysql: imageni run etmek ucun istifade olunur.
4. docker run --name ms9-mysql -e MYSQL_ROOT_PASSWORD=112358 mysql: imageni run etmek ucun istifade olunur
5. docker run -d --name ms9-mysql -e MYSQL_ROOT_PASSWORD=112358 mysql: imageni detach modda run etmek ucun istifade olunur
6. docker stop container id: run olan containeri dayandirir
7. docker exec -it {container id} /bin/sh: containeri interaktiv run edir.
8. docker rm {container id}: containeri silir
9. docker run -d -p 9093:80 --name ms9-nginx nginx: container detach modda bizim gosterdiyimiz porta calanir ve run olur.
10. docker network ls:
11. vim docker-compose.yaml: kompose fayli yardiriq
12. docker-compose up veya docker compose up -d: hemin yaratdigimiz compose faylini ayaga qaldirir
13. docker compose stop: compose faylini dayandirir
14. docker compose down: neyinki dayandirir hemcininde silir
15. docker volume rm {volume name}: volume-i silir
16. docker volume ls: volume-lerin listini verir
17. docker volume prune: istifade olunmaya butun volume-leri silir
18. docker rmi: image-i remove edir
19. docker rm: container-i remove edir
20. docker exec -it {container id} /bin/sh(/bash): container-in icine girmek ucun(interaktiv) idare etmek ucundur.
21. docker run — name mysql-server -p 3306:3306 -v /opt/data:/etc/mysql/conf.d -e MYSQL_ROOT_PASSWORD=112358 -d mysql
-----------------------------------------------------------------------------------------------------------------------------
Dockerfile
1. docker build . -t ms9:{version}: dockeri build etmek ucundur
2. ./gradlew clean build: dedikde jarlari yaradir
3. java -jar ms9-0.0.1-SNAPSHOT.jar: dedikde proqramimizi run edir
4. docker run ms9:v4: bu komanda hemin duzeltdiyimiz fayli run edir
-----------------------------------------------------------------------------------------------------------------------------
Push image
1. docker image tag ms9:v11 parvin02/test-docker:v11: tag adi yaradiriq
2. docker push parvin02/test-docker:v11: image-i docker hub-a push edir
-----------------------------------------------------------------------------------------------------------------------------
Dockerfile
FROM alpine
# build phase
RUN apk add --no-cache openjdk17
COPY build/libs/docker2-0.0.1-SNAPSHOT.jar /app/
WORKDIR /app/
# run phase
ENTRYPOINT ["java"]
CMD ["-jar", "/app/docker2-0.0.1-SNAPSHOT.jar"]
FROM alpine:3.11.2
RUN apk add --no-cache openjdk11
COPY build/libs/ms9-0.0.1-SNAPSHOT.jar /app/
ENTRYPOINT ["java"]
CMD ["-jar", "/app/ms9-0.0.1-SNAPSHOT.jar"]
RUN -> build fazada iwleyir
ENTRYPOINT -> run
CMD -> run
---------------------------------------------------------------------------------------------
docker-compose.yaml
version: '3.1'
services:
mysql:
hostname: mysql-hostname
image: mysql
volumes:
- db_data:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: 112358
ports:
- 3306:3306
networks:
- ms9_netw
ms9:
build: .
image: ms9:v11
restart: always
ports:
- 8080:8080
environment:
DB_CONNECTION_IP: "mysql-hostname"
networks:
- ms9_netw
depends_on:
- mysql
networks:
ms9_netw:
volumes:
db_data:---------------------------------------------------------------------------------------------
Postgres
1. psql -U postgres: postgres-e daxil olmaga
2. \du:
3. \l: database listleri gosterir
4. \c{database name}: hemin databazaya qowulur
5. psql -h localhost -p {teyin etdiyimiz port} -U postgres: lokaldan postgrese connection
qurmaq ucundur
6. \d: tableda ralationlari gosterir
7. \dt: describe table
8. \d{table name}: table icini gosterir, yeni describe edir
---------------------------------------------------------------------------------------------
1. docker run --name bongamin -p 1234:5432 -e POSTGRES_PASSWORD=password -d-v ./postgres-data:/var/lib/postgresql/data postgres:alpine: bu komanda volume ile birlikde
postgresi ayaga qaldirir
---------------------------------------------------------------------------------------------
1. docker image build -t jdk-image-from-dockerfile .:
--------------------------------------------------------------------------------------
How to push image to Docker Hub
1. sudo docker login
2. sudo docker tag ms10:1.0 parvin02/ms10:1.0
3. sudo docker push parvin02/ms10:1.0
---------------------------------------------------------------------------------------------
1. docker rmi $(docker images -aq) -> butun imageleri silir
2. docker rmi -f $(docker images -aq) -> mecburen butun imageleri silir
3. docker stop $(docker images -aq) -> butun imageleri stop edir
4. docker rm $(docker ps -aq) -> bugun running containerleri silir
5. docker stop [container id] -> running containeri stop edir
6. docker rm [container id] -> running veya non running container silir
7. docker ps -> run olan containerlerin siyahisini gosterir
8. docker run -d --name [istediyimiz ad] -e MYSQL_ROOT_PASSWORD=[istediyimiz password] mysql ->
detach modda istediymiz image-nin containerini qaldirir
9. docker search [image name] -> docker hub-da image axtarir
10. docker images -> localda image-leri axtarir
11. docker ps -a -> butun running and non running containerlerin siyahisini bize verir
12. docker run -d --name [ad veririk] -e MYSQL_ROOT_PASSWORD=[password veririk] mysql:[version]
13. docker exec -it [container id] /bin/sh(bash) -> containerin icine girmek ucundur
14. docker start [container id] -> stop olunmuw containeri start edir
15. docker run -p [bizim port:application port] -d --name [ad veririk] ngix -> burada port
expose edirik. Mes: docker run -p 9091:80 -d --name some-nginx5 nginx
16. docker rm -f [container id] -> run olan container-i mecburen silir
17. docker volume rm [volume name] -> qeyd etdiyimiz volumu silir
18. docker network prune -> butun networklari simek ucundur
19. docker system prune -a -> her weyi silmek ucundur
20. docker volume rm $(docker volume ls -q) -> butun volumeleri silir
21. docker logs [container id] -> container-in loqlarini verir
DOCKERIZE
1. ./gradlew assemble (veya gradle assemble) -> bu komanda proyekti build edir lakin testleri build etmir. Yeni
./gradlew build ferqi testleri build etmir
2. java -jar ms7-0.0.1-SNAPSHOT.jar -> cmd-de proyektimizi run edir. Bu faylin yerlewdiyi yeri
tapib bu komandani icra etmek lazimdir
3. docker build . -t ms7:v1 -> docker image yaradir
4. docker tag ms7:v1 parvin02/ms7:v1
5. docker push parvin01/ms7:v1 -> yuxaridaki komdada yaradir, bu komandada ise docker hub-a push
edir.
*** eger alinmasa o zaman : docker login -> yazmaq lazimdir
6.
--------------------------------------------------------------------------------------------------
*** Docker in Docker
1. docker run docker docker images -> docker in docker sayilir
2. docker run docker -v /var/run/docker.sock:/var/run/docker.sock docker images -> creates a
docker container and mounts local docker socket to the container
3.
--------------------------------------------------------------------------------------------------
*** Multiple java versions with script
filename.sh
docker run containerName:v1 "$@"
Комментарии
Отправить комментарий