Skip to content

Latest commit

 

History

History
65 lines (35 loc) · 1.51 KB

README.md

File metadata and controls

65 lines (35 loc) · 1.51 KB

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

Getting Started

You will need…

For Windows - you will also need

Creating a docker container

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.

Running a docker container

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’

Getting the container's logs

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

Additional UFW ports

If you need to open additional ports, add:

sudo ufw allow <port number>/tcp

Other Docker Commands

  • List all containers

    sudo docker ps -a -q

  • Remove all containers

    sudo docker rm [$(sudo docker ps -a -q)]