04/02/2018 - DOCKER
Bu örneğimizde bir uygulamayı docker container içine kopyalayacağız. Bu uygulama dosyalarına ulaşımı, dış dünyaya kapatmak için kullanılan bir taktiktir.
ubuntu@linux:~/symfony$ tree -a
.
├── docker
│ ├── docker-compose.yml
│ └── nginx
│ └── Dockerfile
├── index.html
└── src
├── src-1.html
└── src-2.html
3 directories, 5 files
ubuntu@linux:~/symfony$ cat index.html
Hello!
ubuntu@linux:~/symfony$ cat src/src-1.html
SRC 1
ubuntu@linux:~/symfony$ cat src/src-2.html
SRC 2
ubuntu@linux:~/symfony$ cat docker/docker-compose.yml
version: '3'
services:
nginx_img:
container_name: nginx_con
build:
context: ..
dockerfile: ./docker/nginx/Dockerfile
ports:
- 1000:80
ubuntu@linux:~/symfony$ cat docker/nginx/Dockerfile
FROM nginx:1.13.8
WORKDIR /usr/share/nginx/html
COPY . .
ubuntu@linux:~/symfony/docker$ docker-compose up -d
ubuntu@linux:~$ curl localhost:1000
Hello!
ubuntu@linux:~$ curl localhost:1000/src/src-1.html
SRC 1
ubuntu@linux:~$ curl localhost:1000/src/src-2.html
SRC 2
ubuntu@linux:~$ docker exec -it nginx_con ls -l
-rw-r--r-- 1 root root 537 Dec 26 2017 50x.html
drwxrwxr-x 3 root root 4096 Dec 25 09:40 docker
-rw-rw-r-- 1 root root 7 Dec 25 09:39 index.html
drwxrwxr-x 2 root root 4096 Dec 25 09:39 src
ubuntu@linux:~$ docker exec -it nginx_con ls -l src
-rw-rw-r-- 1 root root 6 Dec 25 09:39 src-1.html
-rw-rw-r-- 1 root root 6 Dec 25 09:39 src-2.html
ubuntu@linux:~$ docker exec -it nginx_con ls -l docker
-rw-rw-r-- 1 root root 199 Dec 25 09:34 docker-compose.yml
drwxrwxr-x 2 root root 4096 Dec 25 09:40 nginx
ubuntu@linux:~$ docker exec -it nginx_con ls -l docker/nginx
-rw-rw-r-- 1 root root 59 Dec 25 09:40 Dockerfile