# Updates
apt-get update && apt-get install -y vim-nox git-core ufw curl atop htop build-essential libssl-dev linux-image-amd64 linux-headers-amd64
# Updates Profile init scripts
cd ~/
curl -sSL https://gist.githubusercontent.com/justsml/b667f158731fd054cd38/raw/5778dbb5d3d138ccf99ae1bf973457ce89661362/.bash_aliases > .bash_aliases_new
cat .bash_aliases_new >> .bash_aliases
# Read into current shell (login steps already missed the aliases file)
source .bash_aliases
# Install Docker
curl -sSL https://get.docker.com/ | sh
# Create Shared Folder On HOST for the Docker DB Instances
mkdir -p /mongodb/db
mkdir -p /elastic
=========
Only for SELinux Enabled Systems
# SELinux fixes (optional)
# chcon -Rt svirt_sandbox_file_t /mongodb
# chcon -Rt svirt_sandbox_file_t /elastic
=========
mkdir -p /mongodb/db
docker run -p 127.0.0.1:27017:27017 --name mongo -v /mongodb:/data -d mongo:3 bash -c 'mongod --bind_ip 0.0.0.0 --logpath /data/mongodb.log --logappend --dbpath /data/db --storageEngine=wiredTiger'
mkdir -p /elastic
echo "path:" > /elastic/elasticsearch.yml
echo " logs: /data/elastic-logs" >> /elastic/elasticsearch.yml
echo " data: /data/elastic-data" >> /elastic/elasticsearch.yml
docker run --name elastic -d -p 9200:9200 -p 9300:9300 -v /elastic:/data elasticsearch bash -c 'elasticsearch -Des.config=/data/elasticsearch.yml'
- Add a blank file named
Dockerfile
in your project root. - (Optional) Add a
.dockerignore
using .gitignore rules to exclude large non-essential paths. By default all project files are included.
# Example for NodeJS
FROM node:0.12
EXPOSE [3000]
COPY . /app/
WORKDIR /app
RUN apt-get update \
&& apt-get dist-upgrade -y
RUN ["npm", "install"]
# Overridable Command
CMD ["npm", "start"]
It's easier to show how to start using the dockerfile and inspect the result via console.
In terminal, cd
to your project folder and run the following docker build
command everytime you make a change or want to include OS upgrades)
docker build -t app-name-here .
===========
docker run -d --name webapp01 --link mongo:mongo --link elastic:elastic app-name-here
docker run -it --name webapp01 --link mongo:mongo --link elastic:elastic app-name-here
===========
docker rm -f webapp01
# rerun `docker run...` from ^^^
Note: Data is mounted to host server at /mongodb
docker rm -f mongo elastic
# OR
docker rm -f elastic
docker rm -f mongo