rapa@manager:~/0824$ echo "test123" | docker secret create mysql_password -
twm1ixh7gcrqchh1nn0dx6bm5
rapa@manager:~/0824$ docker secret inspect mysql_password
[
{
"ID": "twm1ixh7gcrqchh1nn0dx6bm5",
"Version": {
"Index": 403
},
"CreatedAt": "2022-08-24T07:25:16.690340785Z",
"UpdatedAt": "2022-08-24T07:25:16.690340785Z",
"Spec": {
"Name": "mysql_password",
"Labels": {}
}
}
]
컨테이너에 붙여 생성하고나서 컨테이너 안에 파일 형태로 존재하기 때문에 이곳에서는 볼 수 없음
MSP업체에서는 내가 입력한 pw가 test123인지 확인할 수 없어야 함
데이터베이스 배포
컨테이너의 /run/secrets밑에 mysql_root_password, mysql_password 형태로 들어간다.
rapa@manager:~/0824$ docker service create --name sql --secret source=mysql_password,target=mysql_root_password --secret source=mysql_password,target=mysql_password -e MYSQL_ROOT_PASSWORD_FILE="/run/secrets/mysql_root_password" -e MYSQL_PASSWORD_FILE="/run/secrets/mysql_password" -e MYSQL_DATABASE="testdb" --constraint node.role==manager mysql:5.7
image mysql:5.7 could not be accessed on a registry to record
its digest. Each node will access mysql:5.7 independently,
possibly leading to different nodes running different
versions of the image.
klujh0uzukz8yexln89x03le8
overall progress: 1 out of 1 tasks
1/1: running [==================================================>]
verify: Service converged
source=mysql_password는 로컬 호스트, target=mysql_root_password는 컨테이너
rapa@manager:~/0824$ docker secret ls
ID NAME DRIVER CREATED UPDATED
twm1ixh7gcrqchh1nn0dx6bm5 mysql_password 33 minutes ago 33 minutes ago
rapa@manager:~/0824$ docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
5d2cd03f845d mysql:5.7 "docker-entrypoint.s…" 10 minutes ago Up 10 minutes 3306/tcp, 33060/tcp sql.1.3pwd620b73wz4erxu1ved2q87
67d63beb412d portainer/portainer "/portainer" About an hour ago Up About an hour 8000/tcp, 0.0.0.0:9000->9000/tcp, :::9000->9000/tcp portainer
rapa@manager:~/0824$ docker container exec 5d2cd03f845d ls /run/secrets/
mysql_password
mysql_root_password
rapa@manager:~/0824$ docker container exec 5d2cd03f845d cat /run/secrets/mysql_password
test123
index.html 내용을 가져다가 webconfig 파일 만들기
rapa@manager:~/0824$ echo "hello world" > index.html
rapa@manager:~/0824$ docker config create webcfg index.html
v7a9vi866vv89mi86te2fgula
rapa@manager:~/0824$ docker config ls
ID NAME CREATED UPDATED
v7a9vi866vv89mi86te2fgula webcfg 31 seconds ago 31 seconds ago
rapa@manager:~/0824$ docker config inspect webcfg
[
{
"ID": "v7a9vi866vv89mi86te2fgula",
"Version": {
"Index": 1613
},
"CreatedAt": "2022-08-24T08:06:39.334220228Z",
"UpdatedAt": "2022-08-24T08:06:39.334220228Z",
"Spec": {
"Name": "webcfg",
"Labels": {},
"Data": "aGVsbG8gd29ybGQK"
}
}
]
rapa@manager:~/0824$ echo aGVsbG8gd29ybGQK | base64 -d
hello world
rapa@manager:~/0824$ docker service create --replicas 1 --constraint node.role==manager --name webcfg -p 8888:80 --config source=webcfg,target=/usr/share/nginx/html/index.html nginx
image nginx:latest could not be accessed on a registry to record
its digest. Each node will access nginx:latest independently,
possibly leading to different nodes running different
versions of the image.
ivkv9wgsskspoouix78wi6zyh
overall progress: 1 out of 1 tasks
1/1: running [==================================================>]
verify: Service converged
211.183.3.100:8888 접속하면 hello world가 보인다.