브릿지 네트워크 아래에서 3 개의 서비스 (db, nginx 및 웹 서비스)를 함께 연결하고 내 로컬 호스트 또는 컨테이너 내부의 다른 서비스에서 찌를 수 있고 웹 서비스를위한 대화 형 터미널. 이것을 어떻게 할 수 있습니까? 웹 서비스가 더 거점으로 mhart/alpine-node:6.7.0
을 사용하고Docker가있는 터미널 링크로 작성
version: '2'
services:
web:
build:
context: .
dockerfile: Dockerfile-alpine
command: /bin/bash
ports:
- "5000:5000"
volumes:
- $REPO_DIR:/repository
links:
- db
- nginx
nginx:
image: nginx:stable-alpine
ports:
- "8080:8080"
volumes:
- $NGINX_STATIC_DIR:/var/www/static
- $NGINX_CONFIG_FILE:/etc/nginx/nginx.conf
db:
image: mysql/mysql-server
ports:
- "3307:3306"
environment:
MYSQL_USER: $MYSQL_USER
MYSQL_PASSWORD: $MYSQL_PASSWORD
MYSQL_DATABASE: $MYSQL_DATABASE
MYSQL_ROOT_PASSWORD: $MYSQL_ROOT_PASSWORD
volumes:
- $DB_DATA_DIR:/var/lib/mysql
- $DB_LOG_DIR:/var/log/mysql
일부 유틸리티 Python3.5와 플라스 플러스를 추가
내 고정 표시기-작성 구성은 다음과 같다.
내가 docker-compose run web
이라면 대화 형 터미널에 액세스 할 수 있지만 db 및 nginx 서비스는 제대로 부팅/링크되지 않습니다. 나는 다음과 같은 출력을 얻을 : 내부에서
Starting courseadmin_nginx_1
Starting courseadmin_db_1
bash-4.3#
그리고 더 네트워크 포렌식을 컨테이너가 둘의 nginx 또는 데시벨이 있는지 변합니다. 나는이 호스트 호스트 시스템에 mysql이 설치되어 있다는 db 서비스에 대한 포트 충돌을 실제로 만들었 기 때문에 docker-compose run
으로보고하지 않은 것이므로 docker-compose up
을 사용하여이 주장을 계속 뒷받침 할 수 있습니다. 내가 docker-compose up
를하려고하면 다른 한편으로
, 나는 훨씬 더 적극적인 추적을 얻을 수 있지만, 대화 형 터미널 :
Starting courseadmin_nginx_1
Recreating courseadmin_db_1
Recreating courseadmin_web_1
Attaching to courseadmin_nginx_1, courseadmin_db_1, courseadmin_web_1
db_1 | Initializing database
courseadmin_web_1 exited with code 0
db_1 | Database initialized
db_1 | MySQL init process in progress...
db_1 | Warning: Unable to load '/usr/share/zoneinfo/iso3166.tab' as time zone. Skipping it.
db_1 | Warning: Unable to load '/usr/share/zoneinfo/zone.tab' as time zone. Skipping it.
db_1 | mysql: [Warning] Using a password on the command line interface can be insecure.
db_1 | mysql: [Warning] Using a password on the command line interface can be insecure.
db_1 | mysql: [Warning] Using a password on the command line interface can be insecure.
db_1 | mysql: [Warning] Using a password on the command line interface can be insecure.
db_1 |
db_1 | /entrypoint.sh: ignoring /docker-entrypoint-initdb.d/*
db_1 |
db_1 |
db_1 | MySQL init process done. Ready for start up.
db_1 |
나는 나의 세 가지 용기의 대화 형 단자와 적절한 연결을 달성하기 위해 무엇을 할 수 없다 ?
은'고정 표시기 - compose' 문서 내가 약 여기에서 찾을 수 있습니다 links''에 대한 특정 부분을 계속 얘기 : https://docs.docker.com/compose/networking/#/links – d00bsm3n
그레이트 포스트! 분명히 나에게 많은 도움이된다. 그러나 나는/bin/bash 할 일이 없기 때문에 나의 웹 컨테이너가 계속 죽어 가기 때문에 docker exec -ti $ container_id를 할 수 없다. 어떤 진입 점도 지나치지 않고 살아갈 수있는 방법이 있습니까? –
** 웹 컨테이너가 죽는 이유에 대해 확실하지 않은 경우에는 [here] (http://stackoverflow.com/a/28214133/6942595)를 참조하십시오. 나머지는, 당신이 당신의 '웹'서비스로 얻으려는 것을 OP에서 조금 더 자세히 설명 할 수 있습니까? 나에게 당신은 간단하게'image : alpine'을 할 수있는 것 같아요. 그러면'exec '라는 쉘을 시작할 수있는 컨테이너를 설정할 것입니까? – d00bsm3n