Skip to content

qiao-wei/docker_remote

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

docker_remote

简体中文 English

📦 Why do this ?

My program need to docker build first ,and then push to the harbor, last deployment with k8s.

But the hard disk of my local machine is too small. so I don't want to install docker in local, so I need to send the program to the remote machine with docker,and then execute the script. It is so complex.

So I think that if all this can be done directly locally. Kubectl can operate remote machines directly locally, But docker cant do that , so I want to implement one .

📦 Why not use the docker api ?

too complex !

📦 Build

Server

CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o server-liunx server/main.go 

Client

go build -o docker client/main.go 

Notice : In order to use the same as the docker, the client is named docker. Of course, you can also name it another , but please change it to the name you named when you encounter the docker command later

StartUp

Server

Copy the "server" to the machine with docker

nohup server-liunx -p 50000 &

Client

> Set the environment variable : DOCKER_REMOTE_SERVER , point to the IP and port of the server

  • linux mac osx
export DOCKER_REMOTE_SERVER=ip:port

e.g.

export DOCKER_REMOTE_SERVER=192.168.1.16:50000

Write the above script to ~ /.bash_profile file

then

source ~/.bash_profile 

notice : Write "source ~/.bash_profile" to ~/.zshrc if it doesn't work after Mac OSX restarts

If there is no ~/.zshrc, please create a new one.

  • windows

My Computer right button Properties -> Advanced settings -> Environment Variable

> StartUp

Enter the directory where the "docker" is located. It is recommended to copy the docker to $path

type

docker

View all commands .

In fact, it's the docker command, such as viewing all the image lists

docker images 

If prompt "command not find" in work directory, you can type

./docker 

Or copy docker to $path

About

execute remote machine's docker command on local machine .

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published