Created
April 4, 2017 19:16
-
-
Save thenayr/f7f3c7396b3392a38bedac543d595497 to your computer and use it in GitHub Desktop.
Docker container communication over same network example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NGINX_CONTAINER_NAME := nginx-test | |
NGINX_CONTAINER_IMAGE := nginx:1.11.12-alpine | |
TOOLBOX_CONTAINER_NAME := docker-toolbox | |
TOOLBOX_CONTAINER_IMAGE := sjourdan/toolbox | |
NETWORK := test-network | |
.PHONY : check clean | |
check: | |
-@ docker network create $(NETWORK) | |
-@ docker run --network=$(NETWORK) --name=$(NGINX_CONTAINER_NAME) -d $(NGINX_CONTAINER_IMAGE) | |
-@ docker run --network=$(NETWORK) --name=$(TOOLBOX_CONTAINER_NAME) $(TOOLBOX_CONTAINER_IMAGE) \ | |
nc nginx-test 80 && \ | |
echo "Connected succesfully" | |
clean: | |
-@ docker stop $(NGINX_CONTAINER_NAME) && \ | |
docker rm -f $(NGINX_CONTAINER_NAME) $(TOOLBOX_CONTAINER_NAME) && \ | |
docker rmi $(NGINX_CONTAINER_IMAGE) $(TOOLBOX_CONTAINER_IMAGE) | |
docker network rm $(NETWORK) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment