Deprecate some Dockerize topics in favor of library ones (#3735)

This commit is contained in:
Misty Stanley-Jones 2017-07-12 12:06:07 -07:00 committed by John Mulhausen
parent 9c245acd35
commit 0c7d3b5f4c
9 changed files with 16 additions and 717 deletions

View File

@ -1252,24 +1252,28 @@ samples:
title: ASP.NET Core + SQL Server on Linux
- path: /engine/examples/couchdb_data_volumes/
title: CouchDB
- path: /engine/examples/couchbase/
- path: /samples/couchbase/
title: Couchbase
nosync: true
- path: /compose/django/
title: Django and PostgreSQL
- path: /engine/examples/mongodb/
- path: /samples/mongo/
nosync: true
title: MongoDB
- path: /engine/examples/postgresql_service/
title: PostgreSQL
- path: /compose/rails/
title: Rails and PostgreSQL
- path: /engine/examples/running_redis_service/
- path: /samples/redis/
title: Redis
nosync: true
- path: /engine/examples/running_riak_service/
title: Riak
- path: /engine/examples/running_ssh_service/
title: SSHd
- path: /compose/wordpress/
- path: /samples/wordpress/
title: WordPress
nosync: true
manuals:
- sectiontitle: Docker Enterprise Edition

View File

@ -1,145 +0,0 @@
---
description: Getting started with Compose and WordPress
keywords: documentation, docs, docker, compose, orchestration, containers
title: "Quickstart: Compose and WordPress"
---
You can use Docker Compose to easily run WordPress in an isolated environment
built with Docker containers. This quick-start guide demonstrates how to use
Compose to set up and run WordPress. Before starting, you'll need to have
[Compose installed](install.md).
### Define the project
1. Create an empty project directory.
You can name the directory something easy for you to remember.
This directory is the context for your application image. The
directory should only contain resources to build that image.
This project directory will contain a `docker-compose.yml` file which will
be complete in itself for a good starter wordpress project.
>**Tip**: You can use either a `.yml` or `.yaml` extension for
this file. They both work.
2. Change directories into your project directory.
For example, if you named your directory `my_wordpress`:
cd my_wordpress/
3. Create a `docker-compose.yml` file that will start your
`WordPress` blog and a separate `MySQL` instance with a volume
mount for data persistence:
```none
version: '3'
services:
db:
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: somewordpress
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress
wordpress:
depends_on:
- db
image: wordpress:latest
ports:
- "8000:80"
restart: always
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
volumes:
db_data:
```
> **Notes**:
>
* The docker volume `db_data` persists any updates made by Wordpress
to the database. [Learn more about docker volumes](/engine/tutorials/dockervolumes.md)
>
* WordPress Multisite works only on ports `80` and `443`.
{: .note-vanilla}
### Build the project
Now, run `docker-compose up -d` from your project directory.
This runs [docker-compose up](/compose/reference/up/) in detached mode, pulls
the needed images, and starts the wordpress and database containers, as shown in
the example below.
$ docker-compose up -d
Creating network "my_wordpress_default" with the default driver
Pulling db (mysql:5.7)...
5.7: Pulling from library/mysql
efd26ecc9548: Pull complete
a3ed95caeb02: Pull complete
...
Digest: sha256:34a0aca88e85f2efa5edff1cea77cf5d3147ad93545dbec99cfe705b03c520de
Status: Downloaded newer image for mysql:5.7
Pulling wordpress (wordpress:latest)...
latest: Pulling from library/wordpress
efd26ecc9548: Already exists
a3ed95caeb02: Pull complete
589a9d9a7c64: Pull complete
...
Digest: sha256:ed28506ae44d5def89075fd5c01456610cd6c64006addfe5210b8c675881aff6
Status: Downloaded newer image for wordpress:latest
Creating my_wordpress_db_1
Creating my_wordpress_wordpress_1
> **Note:** WordPress Multisite works only on ports `80` and/or `443`.
If you get an error message about binding `0.0.0.0` to port `80` or `443`
(depending on which one you specified), it is likely that the port you
configured for WordPress is already in use by another service.
### Bring up WordPress in a web browser
At this point, WordPress should be running on port `8000` of your Docker Host,
and you can complete the "famous five-minute installation" as a WordPress
administrator.
> **Note:** The WordPress site will not be immediately available on port `8000`
because the containers are still being initialized and may take a couple of
minutes before the first load.
If you are using [Docker Machine](/machine/), you can run the command
`docker-machine ip MACHINE_VM` to get the machine address, and then open
`http://MACHINE_VM_IP:8000` in a web browser.
If you are using Docker for Mac or Docker for Windows, you can use
`http://localhost` as the IP address, and open `http://localhost:8000` in a web
browser.
![Choose language for WordPress install](images/wordpress-lang.png)
![WordPress Welcome](images/wordpress-welcome.png)
### Shutdown and Cleanup
The command [docker-compose down](/compose/reference/down/) removes the
containers and default network, but preserves your Wordpress database.
The command `docker-compose down --volumes` removes the containers, default
network, and the Wordpress database.
## More Compose documentation
- [User guide](index.md)
- [Installing Compose](install.md)
- [Getting Started](gettingstarted.md)
- [Get started with Django](django.md)
- [Get started with Rails](rails.md)
- [Command line reference](./reference/index.md)
- [Compose file reference](compose-file.md)

View File

@ -1,277 +0,0 @@
---
description: Dockerizing a Couchbase service
keywords: docker, example, package installation, networking, couchbase
title: Dockerize a Couchbase service
---
This example shows how to start a [Couchbase](http://couchbase.com) server using
Docker Compose, configure it using its [REST
API](http://developer.couchbase.com/documentation/server/4.0/rest-api/rest-endpoints-all.html),
and query it.
Couchbase is an open source, document-oriented NoSQL database for modern web,
mobile, and IoT applications. It is designed for ease of development and
Internet-scale performance.
## Start Couchbase server
Couchbase Docker images are published at [Docker
Hub](https://hub.docker.com/_/couchbase/).
Start Couchbase server:
```bash
$ docker run -d --name db -p 8091-8093:8091-8093 -p 11210:11210 couchbase
```
The purpose of each port exposed is explained at [Couchbase Developer Portal -
Network
Configuration](http://developer.couchbase.com/documentation/server/4.1/install/install-ports.html).
Logs can be seen using the `docker logs` command:
```bash
$ docker logs db
Starting Couchbase Server -- Web UI available at http://<ip>:8091
```
> **Note**: The examples on this page assume that the Docker Host
> is reachable on `192.168.99.100`. Substitute `192.168.99.100` with
> the actual IP address of your Docker Host. If you're running
> Docker using Docker machine, you can obtain the IP address
> of the Docker host using `docker-machine ip <MACHINE-NAME>`.
The logs show that Couchbase console can be accessed at
`http://192.168.99.100:8091`. The default username is `Administrator` and the
password is `password`.
## Configure Couchbase Docker container
By default, Couchbase server needs to be configured using the console before it
can be used. This can be simplified by configuring it using the REST API.
### Configure memory for Data and Index service
Data, Query and Index are three different services that can be configured on a
Couchbase instance. Each service has different operating needs. For example,
Query is CPU intensive operation and so requires a faster processor. Index is
disk heavy and so requires a faster solid state drive. Data needs to be
read/written fast and so requires more memory.
Memory needs to be configured for Data and Index service only.
```bash
$ curl -v -X POST http://192.168.99.100:8091/pools/default -d memoryQuota=300 -d indexMemoryQuota=300
* Hostname was NOT found in DNS cache
* Trying 192.168.99.100...
* Connected to 192.168.99.100 (192.168.99.100) port 8091 (#0)
> POST /pools/default HTTP/1.1
> User-Agent: curl/7.37.1
> Host: 192.168.99.100:8091
> Accept: */*
> Content-Length: 36
> Content-Type: application/x-www-form-urlencoded
>
* upload completely sent off: 36 out of 36 bytes
< HTTP/1.1 401 Unauthorized
< WWW-Authenticate: Basic realm="Couchbase Server Admin / REST"
* Server Couchbase Server is not blacklisted
< Server: Couchbase Server
< Pragma: no-cache
< Date: Wed, 25 Nov 2015 22:48:16 GMT
< Content-Length: 0
< Cache-Control: no-cache
<
* Connection #0 to host 192.168.99.100 left intact
```
The command shows an HTTP POST request to the REST endpoint `/pools/default`.
The host is the IP address of the Docker machine. The port is the exposed port
of Couchbase server. The memory and index quota for the server are passed in the
request.
### Configure Data, Query, and Index services
All three services, or only one of them, can be configured on each instance.
This allows different Couchbase instances to use affinities and setup services
accordingly. For example, if Docker host is running a machine with solid-state
drive then only Data service can be started.
```bash
$ curl -v http://192.168.99.100:8091/node/controller/setupServices -d 'services=kv%2Cn1ql%2Cindex'
* Hostname was NOT found in DNS cache
* Trying 192.168.99.100...
* Connected to 192.168.99.100 (192.168.99.100) port 8091 (#0)
> POST /node/controller/setupServices HTTP/1.1
> User-Agent: curl/7.37.1
> Host: 192.168.99.100:8091
> Accept: */*
> Content-Length: 26
> Content-Type: application/x-www-form-urlencoded
>
* upload completely sent off: 26 out of 26 bytes
< HTTP/1.1 200 OK
* Server Couchbase Server is not blacklisted
< Server: Couchbase Server
< Pragma: no-cache
< Date: Wed, 25 Nov 2015 22:49:51 GMT
< Content-Length: 0
< Cache-Control: no-cache
<
* Connection #0 to host 192.168.99.100 left intact
```
The command shows an HTTP POST request to the REST endpoint
`/node/controller/setupServices`. The command shows that all three services are
configured for the Couchbase server. The Data service is identified by `kv`,
Query service is identified by `n1ql` and Index service identified by `index`.
### Setup credentials for the Couchbase server
Sets the username and password credentials that will subsequently be used for
managing the Couchbase server.
```
curl -v -X POST http://192.168.99.100:8091/settings/web -d port=8091 -d username=Administrator -d password=password
* Hostname was NOT found in DNS cache
* Trying 192.168.99.100...
* Connected to 192.168.99.100 (192.168.99.100) port 8091 (#0)
> POST /settings/web HTTP/1.1
> User-Agent: curl/7.37.1
> Host: 192.168.99.100:8091
> Accept: */*
> Content-Length: 50
> Content-Type: application/x-www-form-urlencoded
>
* upload completely sent off: 50 out of 50 bytes
< HTTP/1.1 200 OK
* Server Couchbase Server is not blacklisted
< Server: Couchbase Server
< Pragma: no-cache
< Date: Wed, 25 Nov 2015 22:50:43 GMT
< Content-Type: application/json
< Content-Length: 44
< Cache-Control: no-cache
<
* Connection #0 to host 192.168.99.100 left intact
{"newBaseUri":"http://192.168.99.100:8091/"}
```
The command shows an HTTP POST request to the REST endpoint `/settings/web`. The
user name and password credentials are passed in the request.
### Install sample data
The Couchbase server can be easily load some sample data in the Couchbase
instance.
```
curl -v -u Administrator:password -X POST http://192.168.99.100:8091/sampleBuckets/install -d '["travel-sample"]'
* Hostname was NOT found in DNS cache
* Trying 192.168.99.100...
* Connected to 192.168.99.100 (192.168.99.100) port 8091 (#0)
* Server auth using Basic with user 'Administrator'
> POST /sampleBuckets/install HTTP/1.1
> Authorization: Basic QWRtaW5pc3RyYXRvcjpwYXNzd29yZA==
> User-Agent: curl/7.37.1
> Host: 192.168.99.100:8091
> Accept: */*
> Content-Length: 17
> Content-Type: application/x-www-form-urlencoded
>
* upload completely sent off: 17 out of 17 bytes
< HTTP/1.1 202 Accepted
* Server Couchbase Server is not blacklisted
< Server: Couchbase Server
< Pragma: no-cache
< Date: Wed, 25 Nov 2015 22:51:51 GMT
< Content-Type: application/json
< Content-Length: 2
< Cache-Control: no-cache
<
* Connection #0 to host 192.168.99.100 left intact
[]
```
The command shows an HTTP POST request to the REST endpoint
`/sampleBuckets/install`. The name of the sample bucket is passed in the
request.
Congratulations, you are now running a Couchbase container, fully configured
using the REST API.
## Query Couchbase using CBQ
[CBQ](http://developer.couchbase.com/documentation/server/4.1/cli/cbq-tool.html),
short for Couchbase Query, is a CLI tool that allows to create, read, update,
and delete JSON documents on a Couchbase server. This tool is installed as part
of the Couchbase Docker image.
Run CBQ tool:
```
docker run -it --link db:db couchbase cbq --engine http://db:8093
Couchbase query shell connected to http://db:8093/ . Type Ctrl-D to exit.
cbq>
```
`--engine` parameter to CBQ allows to specify the Couchbase server host and port
running on the Docker host. For host, typically the host name or IP address of
the host where Couchbase server is running is provided. In this case, the
container name used when starting the container, `db`, can be used. `8093` port
listens for all incoming queries.
Couchbase allows to query JSON documents using
[N1QL](http://developer.couchbase.com/documentation/server/4.1/n1ql/n1ql-language-reference/index.html).
N1QL is a comprehensive, declarative query language that brings SQL-like query
capabilities to JSON documents.
Query the database by running a N1QL query:
```
cbq> select * from `travel-sample` limit 1;
{
"requestID": "97816771-3c25-4a1d-9ea8-eb6ad8a51919",
"signature": {
"*": "*"
},
"results": [
{
"travel-sample": {
"callsign": "MILE-AIR",
"country": "United States",
"iata": "Q5",
"icao": "MLA",
"id": 10,
"name": "40-Mile Air",
"type": "airline"
}
}
],
"status": "success",
"metrics": {
"elapsedTime": "60.872423ms",
"executionTime": "60.792258ms",
"resultCount": 1,
"resultSize": 300
}
}
```
## Couchbase Web Console
[Couchbase Web
Console](http://developer.couchbase.com/documentation/server/4.1/admin/ui-intro.html)
is a console that allows to manage a Couchbase instance. It can be seen at:
`http://192.168.99.100:8091/`
Make sure to replace the IP address with the IP address of your Docker Machine
or `localhost` if Docker is running locally.
![Couchbase Web Console](couchbase/web-console.png)

View File

@ -1,190 +0,0 @@
---
description: Creating a Docker image with MongoDB pre-installed using a Dockerfile and sharing the image on Docker Hub
keywords: docker, dockerize, dockerizing, article, example, docker.io, platform, package, installation, networking, mongodb, containers, images, image, sharing, dockerfile, build, auto-building, framework
title: Dockerize MongoDB
---
## Introduction
In this example, we are going to learn how to build a Docker image with
MongoDB pre-installed. We'll also see how to `push` that image to the
[Docker Hub registry](https://hub.docker.com) and share it with others!
> **Note**: This guide will show the mechanics of building a MongoDB container, but
you will probably want to use the official image on [Docker Hub]( https://hub.docker.com/_/mongo/)
Using Docker and containers for deploying [MongoDB](https://www.mongodb.org/)
instances will bring several benefits, such as:
- Easy to maintain, highly configurable MongoDB instances;
- Ready to run and start working within milliseconds;
- Based on globally accessible and shareable images.
> **Note**: If you do **_not_** like `sudo`, you might want to check out
[*Giving non-root access*](../installation/binaries.md#giving-non-root-access).
## Creating a Dockerfile for MongoDB
Let's create our `Dockerfile` and start building it:
```bash
$ nano Dockerfile
```
Although optional, it is handy to have comments at the beginning of a
`Dockerfile` explaining its purpose:
```conf
# Dockerizing MongoDB: Dockerfile for building MongoDB images
# Based on ubuntu:latest, installs MongoDB following the instructions from:
# http://docs.mongodb.org/manual/tutorial/install-mongodb-on-ubuntu/
```
> **Tip**: `Dockerfile`s are flexible. However, they need to follow a certain
format. The first item to be defined is the name of an image, which becomes
the *parent* of your *Dockerized MongoDB* image.
We will build our image using the latest version of Ubuntu from the
[Docker Hub Ubuntu](https://hub.docker.com/_/ubuntu/) repository.
```conf
# Format: FROM repository[:version]
FROM ubuntu:latest
```
> **Note**: Although Ubuntu systems have MongoDB packages, they are likely to
> be outdated. Therefore in this example, we will use the official MongoDB
> packages.
We will begin with importing the MongoDB public GPG key. We will also create
a MongoDB repository file for the package manager.
```conf
# Installation:
# Import MongoDB public GPG key AND create a MongoDB list file
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927
RUN apt-get install -y --no-install-recommends software-properties-common
RUN echo "deb http://repo.mongodb.org/apt/ubuntu $(cat /etc/lsb-release | grep DISTRIB_CODENAME | cut -d= -f2)/mongodb-org/3.2 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-3.2.list
```
After this initial preparation we can update our packages and install MongoDB.
```conf
# Update apt-get sources AND install MongoDB
RUN apt-get update && apt-get install -y mongodb-org
```
> **Tip**: You can install a specific version of MongoDB by using a list of required packages with versions, e.g.:
>
> ```conf
> RUN apt-get update && apt-get install -y mongodb-org=3.0.1 mongodb-org-server=3.0.1 mongodb-org-shell=3.0.1 mongodb-org-> mongos=3.0.1 mongodb-org-tools=3.0.1
```
MongoDB requires a data directory. Let's create it as the final step of our
installation instructions.
```conf
# Create the MongoDB data directory
RUN mkdir -p /data/db
```
Lastly we set the `ENTRYPOINT` which will tell Docker to run `mongod` inside
the containers launched from our MongoDB image. And for ports, we will use
the `EXPOSE` instruction.
```conf
# Expose port 27017 from the container to the host
EXPOSE 27017
# Set usr/bin/mongod as the dockerized entry-point application
ENTRYPOINT ["/usr/bin/mongod"]
```
Now save the file and let's build our image.
> **Note**: The full version of this `Dockerfile` can be found [here](https://github.com/docker/docker.github.io/blob/master/engine/examples/mongodb/Dockerfile).
## Building the MongoDB Docker image
With our `Dockerfile`, we can now build the MongoDB image using Docker. Unless
experimenting, it is always a good practice to tag Docker images by passing the
`--tag` option to `docker build` command.
```conf
# Format: docker build --tag/-t <user-name>/<repository> .
# Example:
$ docker build --tag my/repo .
```
Once this command is issued, Docker will go through the `Dockerfile` and build
the image. The final image will be tagged `my/repo`.
## Pushing the MongoDB image to Docker Hub
All Docker image repositories can be hosted and shared on
[Docker Hub](https://hub.docker.com) with the `docker push` command. For this,
you need to be logged-in.
```bash
# Log-in
$ docker login
Username:
..
```
```bash
# Push the image
# Format: docker push <user-name>/<repository>
$ docker push my/repo
The push refers to a repository [my/repo] (len: 1)
Sending image list
Pushing repository my/repo (1 tags)
..
```
## Using the MongoDB image
Using the MongoDB image we created, we can run one or more MongoDB instances
as daemon process(es).
```bash
# Basic way
# Usage: docker run --name <name for container> -d <user-name>/<repository>
$ docker run -p 27017:27017 --name mongo_instance_001 -d my/repo
# Dockerized MongoDB, lean and mean!
# Usage: docker run --name <name for container> -d <user-name>/<repository> --noprealloc --smallfiles
$ docker run -p 27017:27017 --name mongo_instance_001 -d my/repo --smallfiles
# Checking out the logs of a MongoDB container
# Usage: docker logs <name for container>
$ docker logs mongo_instance_001
# Playing with MongoDB
# Usage: mongo --port <port you get from `docker ps`>
$ mongo --port 27017
# If using docker-machine
# Usage: mongo --port <port you get from `docker ps`> --host <ip address from `docker-machine ip VM_NAME`>
$ mongo --port 27017 --host 192.168.59.103
```
> **Tip**: If you want to run two containers on the same engine, then you will need to map
the exposed port to two different ports on the host
```bash
# Start two containers and map the ports
$ docker run -p 28001:27017 --name mongo_instance_001 -d my/repo
$ docker run -p 28002:27017 --name mongo_instance_002 -d my/repo
# Now you can connect to each MongoDB instance on the two ports
$ mongo --port 28001
$ mongo --port 28002
```
- [Linking containers](../userguide/networking/default_network/dockerlinks.md)
- [Cross-host linking containers](../admin/ambassador_pattern_linking.md)
- [Creating an Automated Build](/docker-hub/builds/)

View File

@ -1,101 +0,0 @@
---
description: Installing and running a redis service
keywords: docker, example, package installation, networking, redis
title: Dockerize a Redis service
---
Very simple, no frills, Redis service attached to a web application
using a link.
## Create a Docker container for Redis
Firstly, we create a `Dockerfile` for our new Redis
image.
```conf
FROM ubuntu:14.04
RUN apt-get update && apt-get install -y redis-server
EXPOSE 6379
ENTRYPOINT ["/usr/bin/redis-server"]
```
Next we build an image from our `Dockerfile`.
Replace `<your username>` with your own user name.
```bash
$ docker build -t <your username>/redis .
```
## Run the service
Use the image we've just created and name your container `redis`.
Running the service with `-d` runs the container in detached mode, leaving
the container running in the background.
Importantly, we're not exposing any ports on our container. Instead
we're going to use a container link to provide access to our Redis
database.
```bash
$ docker run --name redis -d <your username>/redis
```
## Create your web application container
Next we can create a container for our application. We're going to use
the `-link` flag to create a link to the `redis` container we've just
created with an alias of `db`. This will create a secure tunnel to the
`redis` container and expose the Redis instance running inside that
container to only this container.
```bash
$ docker run --link redis:db -i -t ubuntu:14.04 /bin/bash
```
Once inside our freshly created container we need to install Redis to
get the `redis-cli` binary to test our connection.
```bash
$ sudo apt-get update
$ sudo apt-get install redis-server
$ sudo service redis-server stop
```
As we've used the `--link redis:db` option, Docker
has created some environment variables in our web application container.
```bash
$ env | grep DB_
# Should return something similar to this with your values
DB_NAME=/violet_wolf/db
DB_PORT_6379_TCP_PORT=6379
DB_PORT=tcp://172.17.0.33:6379
DB_PORT_6379_TCP=tcp://172.17.0.33:6379
DB_PORT_6379_TCP_ADDR=172.17.0.33
DB_PORT_6379_TCP_PROTO=tcp
```
We can see that we've got a small list of environment variables prefixed
with `DB`. The `DB` comes from the link alias specified when we launched
the container. Let's use the `DB_PORT_6379_TCP_ADDR` variable to connect to
our Redis container.
```bash
$ redis-cli -h $DB_PORT_6379_TCP_ADDR
$ redis 172.17.0.33:6379>
$ redis 172.17.0.33:6379> set docker awesome
OK
$ redis 172.17.0.33:6379> get docker
"awesome"
$ redis 172.17.0.33:6379> exit
```
We could easily use this or other environment variables in our web
application to make a connection to our `redis`
container.

View File

@ -3,4 +3,6 @@ title: Couchbase
keywords: library, sample, Couchbase
layout: library
repo: couchbase
redirect_from:
- /engine/examples/couchbase/
---

View File

@ -3,4 +3,6 @@ title: MongoDB
keywords: library, sample, MongoDB
layout: library
repo: mongo
redirect_from:
- /engine/examples/mongodb/
---

View File

@ -3,4 +3,6 @@ title: Redis
keywords: library, sample, Redis
layout: library
repo: redis
redirect_from:
- /engine/examples/running_redis_service/
---

View File

@ -3,4 +3,6 @@ title: WordPress
keywords: library, sample, WordPress
layout: library
repo: wordpress
redirect_from:
- /compose/wordpress/
---