This is a quick project to whip up a dockerized container for a friend in both Dockerfile and docker-compose.yml.
The Node.js app starts on port 3000 in the container and is mapped to port 3001 on the host.
In the scripts/ directory, the following scripts exist:
dockerup.sh- usesdocker-compose.ymlwhich usesDockerfileto build an image. Seedocker-compose.yml.origto show how to create a docker container without theDockerfile.dockerbuild.sh- usesDockerfileto build an imagedockerdel.sh- removes images with the namedockerrun.sh- runs the docker image in detached modedockershell.sh- runs the docker image and executesbashinside the shell
The aforementioned scripts should be run in root directory of the repo or the docker files will not be found. See below in the Usage section.
$ ./scripts/dockerup.sh
Recreating docker_node_1 ... done
$ curl localhost:3001
BALLS
On OSX, I used the Docker tutorial by Marcin Pilśniak and learned that you cannot use localhost to hit the app. Instead, docker-machine runs docker containers on a separate IP.
Run this command to find the IP
$ docker-machine ip default
192.168.64.2
$ curl localhost:3001
curl: (7) Failed to connect to localhost port 3001: Connection refused
$ curl 192.168.64.2:3001
BALLS
$ npm i
$ ./node_modules/.bin/dockerlint
INFO: Dockerfile is OK.