Install for Mac: https://docs.docker.com/docker-for-mac/install/ Install for Ubuntu: https://docs.docker.com/engine/installation/linux/docker-ce/ubuntu/ Install for CentOS: https://docs.docker.com/engine/installation/linux/docker-ce/centos/
docker version
docker ps
docker images
docker run | start | stop | kill
docker pull
docker push
Docker HUB: https://hub.docker.com/_/wordpress/
docker run --name some-mysql -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql
docker ps
Docker HUB Wordpress: https://hub.docker.com/_/wordpress/
docker run --name some-wordpress -p 81:80 --link some-mysql:mysql -d wordpress
docker ps
docker stop some-wordpress
docker stop some-mysql
docker start some-mysql
docker start some-wordpress
docker kill some-mysql
docker kill some-wordpress
docker rm some-mysql
docker rm some-wordpress
Have a look at what happens and think about it.
mkdir -p data/{mysql,wordpress}
docker run --name some-mysql -e MYSQL_ROOT_PASSWORD=my-secret-pw -v $(pwd)/data/mysql:/var/lib/mysql -d mysql
docker run --name some-wordpress -p 81:80 --link some-mysql:mysql -v $(pwd)/data/wordpress:/var/www/html -d wordpress
docker kill some-mysql
docker kill some-wordpress
docker rm some-mysql
docker rm some-wordpress
docker run --name some-mysql -e MYSQL_ROOT_PASSWORD=my-secret-pw -v $(pwd)/data/mysql:/var/lib/mysql -d mysql
docker run --name some-wordpress -p 81:80 --link some-mysql:mysql -v $(pwd)/data/wordpress:/var/www/html -d wordpress
Setup docker-machine with xhyve
docker-machine create dev --driver xhyve --xhyve-experimental-nfs-share
docker-machine create --driver digitalocean --digitalocean-access-token $DIGITALOCEAN_TOKEN demo
eval $(docker-machine env demo)
docker run --name some-mysql -e MYSQL_ROOT_PASSWORD=my-secret-pw -v $(pwd)/data/mysql:/var/lib/mysql -d mysql
docker run --name some-wordpress -p 81:80 --link some-mysql:mysql -v $(pwd)/data/wordpress:/var/www/html -d wordpress
docker-machine rm demo
version: '3'
services:
wordpress:
image: wordpress
ports:
- 80:80
environment:
- MYSQL_ROOT_PASSWORD=my-secret-pw
volumes:
- ./data/wordpress:/var/www/html
depends_on:
- mysql
mysql:
image: mysql
environment:
- MYSQL_ROOT_PASSWORD=my-secret-pw
volumes:
- ./data/mysql:/var/lib/mysql
docker-compose up
Create a Dockerfile for MongoDB
############################################################
# Dockerfile to build MongoDB container images
# Based on Ubuntu
############################################################
# Set the base image to Ubuntu
FROM ubuntu
# File Author / Maintainer
MAINTAINER Example McAuthor
# Update the repository sources list
RUN apt-get update
################## BEGIN INSTALLATION ######################
# Install MongoDB Following the Instructions at MongoDB Docs
# Ref: http://docs.mongodb.org/manual/tutorial/install-mongodb-on-ubuntu/
# Add the package verification key
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
# Add MongoDB to the repository sources list
RUN echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | tee /etc/apt/sources.list.d/mongodb.list
# Update the repository sources list once more
RUN apt-get update
# Install MongoDB package (.deb)
RUN apt-get install -y mongodb-10gen
# Create the default data directory
RUN mkdir -p /data/db
##################### INSTALLATION END #####################
# Expose the default port
EXPOSE 27017
# Default port to execute the entrypoint (MongoDB)
CMD ["--port 27017"]
# Set default container command
ENTRYPOINT usr/bin/mongod
docker build -f Dockerfile-mongodb -t puredelight/mongodb:latest .
docker login
docker push puredelight/mongodb:latest
docker run --rm -p 27017:27017 puredelight/mongodb:latest
Connect to local Mongodb