DOCKER
Install docker on Windows 10 laptop/pc
https://docs.docker.com/docker-for-windows/install/
Disable ipv6 in Network Settings - to avoid slow response during running docker commands
C:\ docker search centos
NAME DESCRIPTION
centos The official build of CentOS.
C:\ docker pull centos
C:\ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
centos latest 75835a67d134 13 days ago 200MB
C:\ docker ps
List running docker containers
C:\ docker ps -a
List running & exited containers
C:\ docker run -it -d --privileged=true -h "SERVER01" -p 9000:9000 -p 222:22 --name mycentos centos:latest
(Run in detached mode centos image, as name mycentos, hostname SERVER01, expose port 9000 and 22 (for ssh), give root access privileged. If connect with ssh, use ip 127.0.0.1 port 222).
>can also expose port range. Eg: -p 600-700:600:700
C:\ docker exec -it mycentos bash
(Connect to detached container cmd line)
C:\ docker stop mycentos
(Stop/shutdown server)
C:\ docker start mycentos
(Start server, that is status 'Exited'. No need to rerun using cmd 'docker run')
C:\ docker commit mycentos myserver1:monday
(Save container in status running or exited to image file. If not once removed, changes is lost. Check in 'docker images')
C:\ docker save -o myserver.tar mycentos
(Backup/Save container to file)
C:\ docker load -i myserver.tar
(Restore from tar file to image. Do not use import/export/restore for correct result)
C:\ docker tag <oldname or id> <newname>
C:\docker rm mycentos
(delete container from running, stop, exited status)
C:\ docker rmi centos
(permanently delete docker server from images pulled or saved)
C:\docker stats
>shows cpu & memory usage. Ctrl+c to exit
Other notes:
To enable systemctl
--privileged=true + centos /sbin/init
*require docker run centos /sbin/init
Share Folder With Host C:\share & Docker Image /opt/share
$ docker run -v /c/share:/opt/share centos /sbin/init
yum install openssh-clients openssh-server -y
> vi sshd_config --> UsePAM no
yum install sudo mlocate net-tools -y
https://docs.docker.com/docker-for-windows/install/
Disable ipv6 in Network Settings - to avoid slow response during running docker commands
C:\ docker search centos
NAME DESCRIPTION
centos The official build of CentOS.
C:\ docker pull centos
C:\ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
centos latest 75835a67d134 13 days ago 200MB
C:\ docker ps
List running docker containers
C:\ docker ps -a
List running & exited containers
C:\ docker run -it -d --privileged=true -h "SERVER01" -p 9000:9000 -p 222:22 --name mycentos centos:latest
(Run in detached mode centos image, as name mycentos, hostname SERVER01, expose port 9000 and 22 (for ssh), give root access privileged. If connect with ssh, use ip 127.0.0.1 port 222).
>can also expose port range. Eg: -p 600-700:600:700
C:\ docker exec -it mycentos bash
(Connect to detached container cmd line)
C:\ docker stop mycentos
(Stop/shutdown server)
C:\ docker start mycentos
(Start server, that is status 'Exited'. No need to rerun using cmd 'docker run')
C:\ docker commit mycentos myserver1:monday
(Save container in status running or exited to image file. If not once removed, changes is lost. Check in 'docker images')
C:\ docker save -o myserver.tar mycentos
(Backup/Save container to file)
C:\ docker load -i myserver.tar
(Restore from tar file to image. Do not use import/export/restore for correct result)
C:\ docker tag <oldname or id> <newname>
C:\docker rm mycentos
(delete container from running, stop, exited status)
C:\ docker rmi centos
(permanently delete docker server from images pulled or saved)
C:\docker stats
>shows cpu & memory usage. Ctrl+c to exit
Other notes:
To enable systemctl
--privileged=true + centos /sbin/init
*require docker run centos /sbin/init
Share Folder With Host C:\share & Docker Image /opt/share
$ docker run -v /c/share:/opt/share centos /sbin/init
yum install openssh-clients openssh-server -y
> vi sshd_config --> UsePAM no
yum install sudo mlocate net-tools -y
5 Comments:
> docker pull nginx
> docker run -d -v c:\docker\src\:/usr/share/nginx/html -p 8080:80 --name myweb nginx
place html file in local drive c:\docker\src\index.html
open browser to http://127.0.0.1:8080/index.html
Run with own network segment
> docker network create --subnet=192.168.0.0/24 mynet192
> docker run --net mynet192 --ip 192.168.0.2 -it myubuntu
Startup openssh for first time. Require issue cmd reboot
# yum install openssh-clients openssh-server -y
# reboot
>docker exec -it mycentos bash
# systemctl status sshd
# ssh mzadmin@127.0.0.1
Docker for Windows7 is known as Docker Toolbox.
To connect ssh to docker container in Win7
> docker-machine ip default
192.168.99.100
>use putty, ssh to 192.168.99.100 (not localhost or 127.0.0.1) with exposed ports. eg: 221 -> 22
Run docker as user other than default root
$ docker run --user 1000:1000
$ docker run --user joe:joe
Post a Comment
<< Home