Liveblog:
Hello Docker by Chuck Shotton
Tue, May 12, 2015 at 12:38 PM by Dave Winer ☮.
-
-
-
Install git and docker packages
Pull the sample project folder from GitHub
Test the node.js app locally before running in Docker
Build a local Docker image from the project folder and run it
-
-
-
git --version
docker version
-
-
git clone https://github.com/cshotton/hello_docker.git
Note, you should now be in your home directory. Otherwise, cd to whatever folder you want your sample project to be installed into.
-
cd hello_docker
npm install
-
-
http://your.server.ip:3000/
You should see the environment variable echoed in your web browser
control-C to stop the server
-
-
substitute your username -- this command builds the image in the local docker server's image cache from the Dockerfile in the local directory (the "." arg). You will find the image later by the name you provide after the -t arg, using the docker images command
This command takes a while to run as it is building the full sandbox by pulling in lots of container parts
-
-
This command runs your docker image (username/hello-docker). It maps the external port 8080 to the internal container port 3000. It also passes in and sets the container's HELLO_DOCKER_ENV environment variable.
http://your.server.ip:8080/
-
If you do this, you can use the "sudo docker ps" command to see the running containers and use "sudo docker stop xxx" command, where "xxx" is the first 3 or 4 characters of the process ID shown in the "docker ps" command output.
-
First, you should only "dockerize" an app when you are ready to deploy it. Just build and test as usual with node.js until you are ready to roll it out into production, with multiple containers running on a machine (for example).
You can build your own Docker images and upload them to repositories, like npm, etc. You can also run your own private repository for your images if you don't want them to be repurposed by the general public.
As you might have guessed, you can run multiple copies of the same container on the same machine by just remapping port numbers to the new container (i.e. -p 8080:3000 and -p 3000:3000 on 2 separate docker run commands)
-
Finally, you probably want to read the Docker docs...
git clone https://github.com/cshotton/hello_docker.git