Eu não tenho uma configuração complexa. 2 contêineres, um para meu aplicativo e outro para minha API.
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
8f07c240bee2 nginx "nginx -g 'daemon off" 13 hours ago Up 13 hours 443/tcp, 0.0.0.0:7010->80/tcp simtp_front_1
ae4296bd51d8 simtp_engine "php-fpm" 13 hours ago Up 13 hours 9000/tcp simtp_engine_1
4ae15fcba793 nginx "nginx -g 'daemon off" 6 days ago Up 40 hours 443/tcp, 0.0.0.0:7011->80/tcp simtpapi_front_1
cf04c9567201 simtpapi_engine "php-fpm" 6 days ago Up 40 hours 9000/tcp simtpapi_engine_1
3da782cca9b0 mysql:5.6 "docker-entrypoint.sh" 6 days ago Up 40 hours 0.0.0.0:3308->3306/tcp simtpapi_db_1
Eu quero usar o Guzzle no meu aplicativo para chamar minha API, então eu vinculei meus dois containers juntos, mas quando eu testo o curl ele me retorna:
curl: (7) Failed to connect to simtpapi port 7011: Connection refused
Eu posso pingar o contêiner sem problema:
root@ae4296bd51d8:/var/www/simtp# ping simtpapi
PING simtpapi (172.17.0.3): 56 data bytes
64 bytes from 172.17.0.3: icmp_seq=0 ttl=64 time=0.064 ms
64 bytes from 172.17.0.3: icmp_seq=1 ttl=64 time=0.054 ms
64 bytes from 172.17.0.3: icmp_seq=2 ttl=64 time=0.056 ms
^C--- simtpapi ping statistics ---
3 packets transmitted, 3 packets received, 0% packet loss
round-trip min/avg/max/stddev = 0.054/0.058/0.064/0.000 ms
Aqui está o arquivo docker-compose do meu aplicativo:
front:
image: nginx
ports:
- "7010:80"
links:
- "engine:engine"
volumes:
- ".:/var/www/simtp:ro"
- "./docker/front/default.conf:/etc/nginx/conf.d/default.conf:ro"
engine:
build: ./docker/engine/
external_links:
- "simtpapi_engine_1:simtpapi"
volumes:
- ".:/var/www/simtp:rw"
- "./docker/engine/php.ini:/usr/local/etc/php/conf.d/custom.ini:ro"
working_dir: "/var/www/simtp"
E da minha API:
front:
image: nginx
ports:
- "7011:80"
links:
- "engine:engine"
volumes:
- ".:/var/www/simtp-api:ro"
- "./docker/front/default.conf:/etc/nginx/conf.d/default.conf:ro"
db:
image: mysql:5.6
ports:
- "3308:3306"
environment:
- "MYSQL_ROOT_PASSWORD=password"
engine:
build: ./docker/engine/
volumes:
- ".:/var/www/simtp-api:rw"
- "./docker/engine/php.ini:/usr/local/etc/php/conf.d/custom.ini:ro"
links:
- "db:db"
working_dir: "/var/www/simtp-api"
versão Curl
curl 7.38.0 (x86_64-pc-linux-gnu) libcurl/7.38.0 OpenSSL/1.0.1t zlib/1.2.8 libidn/1.29 libssh2/1.4.3 librtmp/2.3
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtmp rtsp scp sftp smtp smtps telnet tftp
Features: AsynchDNS IDN IPv6 Largefile GSS-API SPNEGO NTLM NTLM_WB SSL libz TLS-SRP
Docker, Docker-machine e docker-compose
PS C:\working_directory\simtp> docker -v
Docker version 1.12.3, build 6b644ec, experimental
PS C:\working_directory\simtp> docker-machine -v
docker-machine.exe version 0.8.2, build e18a919
PS C:\working_directory\simtp> docker-compose -v
docker-compose version 1.8.1, build 004ddae
Na verdade, uso o Docker para Windows (o Windows 10, o modo de desenvolvedor e o contêiner do Hyper-V ativado).