docker api 开发的端口怎么获取?
天蓬老师
天蓬老师 2017-04-25 09:02:30
0
4
781

新版本的docker for Mac去除了docker-machine指令
我现在怎么获取 rest api 开发的端口呢?
比如:
curl -XGET http://localhost:2376/images/... | python -mjson.tool

可是,貌似不是上面的2376端口。
谢谢指教。

天蓬老师
天蓬老师

欢迎选择我的课程,让我们一起见证您的进步~~

reply all(4)
伊谢尔伦

I adopt a compromise method here
Environment: MacOS
Type in the shell: vim ~/.bash_profile, type the following code at the end of the file

alias dest='rest_fun(){ curl --unix-socket /var/run/docker.sock http: | python -mjson.tool ;};rest_fun '

Save and exit, restart the shell.
Then you can use the dest command to implement some functions, such as listing images:
dest /images/json

过去多啦不再A梦

/var/run/docker.sock is used by default for communication. You can use the -H parameter to specify the corresponding listening port.
If you are using the default socket communication mode, you can use curl’s unix-socket method for testing.

curl --unix-socket /var/run/docker.sock http:/v1.24/info

The above instructions are in

Server:
 Version:      1.12.1
 API version:  1.24

Can be executed normally

为情所困

The port here depends on the port bound to your docker daemon.

If no port is specified when the daemon is running, it will be used by defaultunix:///var/run/docker.sock

By default the Docker daemon listens on unix:///var/run/docker.sock and the client must have root access to interact with the daemon. If a group named docker exists on your system, docker applies ownership of the socket to the group.
https://docs.docker.com/engin...

For example when running:

docker -d -H unix:///var/run/docker.sock -H 0.0.0.0:2376

It is equivalent to binding the default socket to 2376 of the local machine, which is what you saidhttp://localhost:2376

世界只因有你

If you don’t want to change the configuration file, just use the mirror to proxy. Pay attention to mounting/var/run/docker.sock

docker run -d -ti -p 2375:2375 -v /var/run/docker.sock:/var/run/docker.sock ehazlett/docker-proxy:latest -i
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!