I created this guide because I wanted to have a docker container on Ubuntu that ran a Node.js server.
Initial problems I ran into before creating this guide:
- The Docker documentation for this doesn't make much sense, is for a very old version of Docker, and uses CentOS.
- The Docker daemon only works on linux and not OS X or Windows - for this you can setup boot2docker
You will need…
- VirtualBox - https://www.virtualbox.org/
For Windows - you will also need
- ssh client (eg. Putty - http://www.chiark.greenend.org.uk/~sgtatham/putty/)
cd /vagrant
sudo docker build -t <your-name>/node .
The .
at the end means take all files in the directory and add them to the container to be built.
sudo docker run -d -i -t baseman/node /bin/bash
You can retrieve the running container id by typing:
sudo docker ps
And then attach to the instance:
sudo docker attach <container id>
You can detach and stop the container instance by typing ‘exit’
First, view the docker containers:
sudo docker ps
Find the CONTAINER_ID
by typing the following command:
sudo docker ps
And then run:
sudo docker logs CONTAINER_ID_HERE
If you need to open additional ports, add:
sudo ufw allow <port number>/tcp
-
List all containers
sudo docker ps -a -q
-
Remove all containers
sudo docker rm [$(sudo docker ps -a -q)]