I use Windows 8.1 for Docker.
After installation when I tried to run docker, for example docker run hello-world
from cmd
I received the following error:
C:\Program Files\Docker Toolbox\docker.exe: An error occurred trying to connect: Post http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.23/containers/create: open //./pipe/docker_engine: The system cannot find the file specified..
See 'C:\Program Files\Docker Toolbox\docker.exe run --help'.
Run docker on Windows with start.sh
script from Docker installation directory.
Output would be like following:
## .
## ## ## ==
## ## ## ## ## ===
/"""""""""""""""""\___/ ===
~~~ {~~ ~~~~ ~~~ ~~~~ ~~~ ~ / ===- ~~~
\______ o __/
\ \ __/
\____\_______/
docker is configured to use the default machine with IP 192.168.99.100
For help getting started, check out the docs at https://docs.docker.com
Start interactive shell
devneo@host MINGW64 ~
$
If you get error about certification, try to regenerated them (default
is the default VM name):
$ docker-machine regenerate-certs -f default
When I tried to access terminal on a container I got following error:
$ docker run -it hello-world
cannot enable tty mode on non tty input
To solve this problem I logged into default
VM via ssh
using docker-machine
, then run container from there:
$ docker-machine ssh default
## .
## ## ## ==
## ## ## ## ## ===
/"""""""""""""""""\___/ ===
~~~ {~~ ~~~~ ~~~ ~~~~ ~~~ ~ / ===- ~~~
\______ o __/
\ \ __/
\____\_______/
_ _ ____ _ _
| |__ ___ ___ | |_|___ \ __| | ___ ___| | _____ _ __
| '_ \ / _ \ / _ \| __| __) / _` |/ _ \ / __| |/ / _ \ '__|
| |_) | (_) | (_) | |_ / __/ (_| | (_) | (__| < __/ |
|_.__/ \___/ \___/ \__|_____\__,_|\___/ \___|_|\_\___|_|
Boot2Docker version 1.11.1, build HEAD : 7954f54 - Wed Apr 27 16:36:45 UTC 2016
Docker version 1.11.1, build 5604cbe
docker@default:~$
docker@default:~$ docker run -i -t ubuntu bash
root@976029f4f84d:/#
Command | Description | Example |
---|---|---|
docker |
list available docker commands | |
docker ps |
shows running containers | |
docker ps -a |
shows all containers, including stopped ones | |
docker images |
lists images | |
docker run repo/image:tag |
runs a container | docker run library/mongo:3.2.6 |
docker run --name <name> -d image |
runs a container in detached mode | docker run --name db -d library/mongo:latest |
docker run --name <name> -p locPort:contPort -d image |
runs a container in detached mode forwarding localport to containers port | docker run --name webapp -p 80:3000 -d umidjons/webserver:1.3 docker run -p 80:3000 -d umidjons/webserver:1.0 bash /var/www/startws.sh |
docker run -i -t image cmd |
runs a container in interactive mode | docker run -it ubuntu bash |
`docker logs <shortId | name>` | shows container's last output once |
`docker logs -f <shortId | name>` | shows container's output in real time |
`docker commit <shortId | name> repo/image:tag` | commits container changes as an image |
`docker stop <shortId | name>` | stops container, useful to stop detached container |
docker exec -i -t repo/image:tag cmd |
start a new process for container, when exits doesn't stops main container with PID 1 | docker exec -i -t ubuntu:latest bash |
`docker rm <shortId | name>` | removes a container |
docker tag image:tag repo/user/image:tag |
tags image with new tags | docker tag myubuntu:1.0 umidjons/webserver:1.0 docker tag 7d9495d03763 umidjons/app-main:latest |
docker push user/image:tag |
pushes image to docker hub | docker push umidjons/webserver:1.0 |
`docker inspect <shortId | name>` | inspects container, information about container, image |
docker-machine |
show usage and available command | docker-machine |
docker-machine ip <vmname> |
find out VM's IP address | docker-machine ip default |
docker-machine ls |
list available VMs | docker-machine ls |
docker-machine status <vmname> |
find out VM's status | docker-machine status default |
docker-machine env <vmname> |
set environment variables for the specified machine | docker-machine env default |
docker save -o imagefullpath.tar image |
saves images into specified location in tar archive format |
docker save -o /c/Users/umidjons/Images/my_webserver_1.0.tar umidjons/webserver:1.0 |
docker load -i image.tar |
loads saved image into docker | docker load -i my_webserver_1.0.tar |
docker build -t image:tag path |
build image according to Dockerfile located in path | docker build -t umidjons/myapp:latest . |
docker run -v locPath:contPath image cmd |
mounts local path to the specified container's path | docker run -i -t -p 3000:3000 -v /c/Users/umidjons/projects/myapp/:/var/www/myapp umidjons/myapp:4.7 node /var/www/myapp/server.js |
docker network ls |
list available networks | docker network ls |
docker network inspect <networkName> |
inspects given network (shows information about that network) | docker network inspect mynetwork |
docker network create --driver bridge <networkName> |
creates isolated network | docker network create --driver bridge mynetwork |
docker run -d --net=<networkName> --name <containerName> <image> |
run container with specifying network | docker run -d --net=mynetwork --name mymongodb mongo docker run -d --net=mynetwork --name nodeapp -p 80:3000 node from now inside nodeapp container we can use host name mymongodb as they are in the same network |
docker-compose build |
build containers from docker-compose.yml file |
|
docker-compose up |
up built containers according to docker-compose.yml |
|
docker-compose up -d |
up built containers in daemon mode according to docker-compose.yml |
|
docker-compose down |
tear down (also removes containers) running containers | |
docker-compose ps |
show information about running containers | |
docker-compose logs |
show logs from all running containers |
Run docker on external 8080 port, map that port into internal 3000 port on the container, create volum that points current directory into containers /var/www directory, then with -w set working directory in the container to /var/www, run node image with command node app.js:
docker run -p 8080:3000 -v $(pwd):/var/www -w "/var/www" node:6 node app.js
many tanks for tips ๐ ๐