BIP KB:
How To - Install And Get Started With Docker
![]() |
Install Docker VPSInstall Docker VPS. If you use Linux, setting up Docker VPS is fairly easy. You can find great instructions straight from Docker's website here. You can also set up Docker on MacOS and Windows - it's a little more complicated, so I recommend using Vagrant's new Docker support feature. |
Docker Online Documentation
Docker has great documentation and a useful interactive online tutorial.Using The Repository
The repository of images with your Docker VPS Server is one of it's best features. The images can be downloaded directly using the pull command and used as the basis of containers for running applications or programming environments (ie. with an ubuntu image you can run containers with ubuntu). If you want to download an ubuntu Docker image, all you have to do is type this into terminal:1 $ docker pull ubuntu
1 $ sudo docker pull ubuntu
1 $ docker pull debian:squeeze
1 $ docker images
2
3 ubuntu 14.10 f14704ad99b8 3 days ago 226.8 MB
4 ubuntu utopic f14704ad99b8 3 days ago 226.8 MB
5 ...
Docker VPS Run Command
After downloading an image, you can run it using Docker VPS with run command, which looks like:1 $ docker run [OPTIONS] IMAGE[:TAG] [COMMAND] [ARG...]
1 $ docker run -t ubuntu:14.04 ls
2
3 bin dev home lib64 mnt proc run srv tmp var
4 boot etc lib media opt root sbin sys usr
1 $ docker run -t ubuntu:14.04
1 $ docker run -i -t ubuntu:14:04 /bin/bash
Running A Redis Container
Now that you know the basics, we can proceed with a more sophisticated example. Imagine that you want to run Redis in our container. (Redis is simple but powerful key-value store. You can read more about it here.) You can find its image in registry using Docker's search command:1 $ docker search redis
1 $ docker search redis | wc -l
2 779
- Should run as deamon
- Data can't disappear when you restart your container
- Should bind to the network to be accessible
- create a directory on your host system
- map directories between your host system and the Docker container so that they instantly synchronize (the change from Docker will appear on your host and vice versa).
1 $ mkdir /var/docker/redis
1 $ docker run -v /host_directory:/container_directory docker_image
2
3 $ docker run -d -v /var/docker/redis:/data dockerfile/redis
1 $ docker run -p $HOSTPORT:$CONTAINERPORT --name CONTAINER -t someimage
1 $ docker run -d -v /var/docker/redis:/data -p 6379:6379 --name=redis dockerfile/redis
Getting More Info About Docker Containers
To see which Docker containers are on your computer, type:1 $ docker ps -a
- CONTAINER ID - every container has unique id
- IMAGE - image that container is based on
- NAMES - names given to your container (Docker gives funny names to your containers if you don't provide your own by passing --name container_name in the run command)
- COMMAND - what command container runs inside
- CREATED - when the container was created
- STATUS - containers can be in two states: exited or running
- PORTS - exposed and forwarded ports
1 $ docker inspect <docker_container_id or name>
1 $ docker inspect redis
1 ...
2 "NetworkSettings": {
3 "Bridge": "docker0",
4 "Gateway": "172.17.42.1",
5 "IPAddress": "172.17.0.143",
6 "IPPrefixLen": 16,
7 "PortMapping": null,
8 "Ports": {
9 "6379/tcp": [
10 {
11 "HostIp": "0.0.0.0",
12 "HostPort": "6379"
13 }
14 ]
15 }
16 },
17 "Path": "redis-server",
18 "ProcessLabel": "",
19 "ResolvConfPath": "/etc/resolv.conf",
20 "State": {
21 "ExitCode": 0,
22 "FinishedAt": "0001-01-01T00:00:00Z",
23 "Paused": false,
24 "Pid": 13335,
25 "Running": true,
26 "StartedAt": "2014-10-03T10:16:20.834865727Z"
27 },
28 "Volumes": {
29 "/data": "/var/docker/redis"
30 },
31 ...
1 $ docker logs redis
1 $ docker top redis
What To Do Next
We've covered so much information about Docker, yet we've only scratched the surface! To learn more, check out this docker cheatsheet and the materials from warsjawa workshops - they will blow you away with helpful information!Tags: Linux, command, education, install, Server, Docker, Docker VPS, install Docker, Redis Container, repository, Setup
Spin Up A VPS Server In No Time Flat
Simple Setup
Full Root Access
Straightforward Pricing
DEPLOY A SECURE VPS SERVER TODAY!Leave a Reply
Feedbacks
![]() This work is licensed under a Creative Commons Attribution- NonCommercial-ShareAlike 4.0 International License. |