• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

docker - 为什么docker-machine显示一个空列表?

[复制链接]
菜鸟教程小白 发表于 2022-8-3 10:11:16 | 显示全部楼层 |阅读模式 打印 上一主题 下一主题

Docker新手在这里。我以this tutorial为例。

我使用的是运行El Cap的Mac。运行适用于Mac的最新Docker。

我创建了一个docker镜像

$ docker build -t pitosalas/sinatra-example .
Sending build context to Docker daemon 9.728 kB
Step 1 : FROM phusion/passenger-ruby23:0.9.19
 ---> 6841e494987f
Step 2 : ENV HOME /root
 ---> Using cache
 ---> 94013634dd29
Step 3 : CMD /sbin/my_init
 ---> Using cache
 ---> 545db4245647
Step 4 : RUN rm -f /etc/service/nginx/down
 ---> Using cache
 ---> 1a5361bf707b
Step 5 : RUN rm /etc/nginx/sites-enabled/default
 ---> Using cache
 ---> 6d884a990bd7
Step 6 : ADD docker/vhost.conf /etc/nginx/sites-enabled/app.conf
 ---> Using cache
 ---> 471fcf124466
Step 7 : RUN mkdir /home/app/webapp
 ---> Using cache
 ---> a0336183d1f0
Step 8 : WORKDIR /tmp
 ---> Using cache
 ---> 38b834783e4f
Step 9 : COPY app/Gemfile /tmp/
 ---> Using cache
 ---> 6541c0cbf6eb
Step 10 : COPY app/Gemfile.lock /tmp/
 ---> Using cache
 ---> 1be89d7bd57b
Step 11 : RUN bundle install
 ---> Using cache
 ---> 3b21f88e6bcf
Step 12 : COPY app /home/app/webapp
 ---> Using cache
 ---> 8bc0cb084d99
Step 13 : RUN chown -R app:app /home/app
 ---> Using cache
 ---> 4bba23481f1f
Step 14 : RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
 ---> Using cache
 ---> d85a89da09c2
Successfully built d85a89da09c2

然后,我检查了运行中的容器。没有任何。如预期的那样:
$ docker-machine ls
NAME   ACTIVE   DRIVER   STATE   URL   SWARM   DOCKER   ERRORS
$ 

接下来,我运行容器:
docker run -p 4567:80 pitosalas/sinatra-example
*** Running /etc/my_init.d/00_regen_ssh_host_keys.sh...
*** Running /etc/my_init.d/30_presetup_nginx.sh...
*** Running /etc/rc.local...
*** Booting runit daemon...
*** Runit started as PID 8
Aug 22 02:07:22 dd3474178cd5 syslog-ng[18]: syslog-ng starting up; version='3.5.6'
ok: run: /etc/service/nginx-log-forwarder: (pid 27) 0s
[ 2016-08-22 02:07:23.8489 28/7fc94dfd9780 age/Wat/WatchdogMain.cpp:1291 ]: Starting Passenger watchdog...
[ 2016-08-22 02:07:23.8769 31/7f07e849d780 age/Cor/CoreMain.cpp:982 ]: Starting Passenger core...
[ 2016-08-22 02:07:23.8770 31/7f07e849d780 age/Cor/CoreMain.cpp:235 ]: Passenger core running in multi-application mode.
[ 2016-08-22 02:07:23.8842 31/7f07e849d780 age/Cor/CoreMain.cpp:732 ]: Passenger core online, PID 31
[ 2016-08-22 02:07:23.9104 42/7f66f0bb5780 age/Ust/UstRouterMain.cpp:529 ]: Starting Passenger UstRouter...
[ 2016-08-22 02:07:23.9155 42/7f66f0bb5780 age/Ust/UstRouterMain.cpp:342 ]: Passenger UstRouter online, PID 42

看起来还不错,但是:
$ docker-machine ls
NAME   ACTIVE   DRIVER   STATE   URL   SWARM   DOCKER   ERRORS
$

仍然没有容器。这是更多文件:
[Dockerfile]
FROM phusion/passenger-ruby23:0.9.19

# Set correct environment variables.
ENV HOME /root

# Use baseimage-docker's init process.
CMD ["/sbin/my_init"]

# Enable nginx and Passenger
RUN rm -f /etc/service/nginx/down

# Remove the default site
RUN rm /etc/nginx/sites-enabled/default

# Create virtual host
ADD docker/vhost.conf /etc/nginx/sites-enabled/app.conf

# Prepare folders
RUN mkdir /home/app/webapp

# Run Bundle in a cache efficient way
WORKDIR /tmp
COPY app/Gemfile /tmp/
COPY app/Gemfile.lock /tmp/
RUN bundle install

# Add our app
COPY app /home/app/webapp
RUN chown -R app:app /home/app

# Clean up when done.
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*


[vhost.conf]
server {
    listen 80;
    server_name localhost;
    root /home/app/webapp/public;

    passenger_enabled on;
    passenger_user app;

    passenger_ruby /usr/bin/ruby2.3;
}

这是我正在使用的目录树:
$ tree
.
├── Dockerfile
├── app
│   ├── Gemfile
│   ├── Gemfile.lock
│   ├── app.rb
│   └── config.ru
├── docker
│   └── vhost.conf
└── tmp

3 directories, 6 files
$

为什么我没有显示正在运行的容器?



Best Answer-推荐答案


Docker机器用于配置远程Docker主机,包括1.12版本之前Windows和MacOS在VM内部使用的主机。由于您使用的是Docker CLI并与引擎进行通讯,因此您不需要Docker机器。

要查看正在运行的容器,请使用docker ps,包括-a参数还可以显示尚未删除的退出容器。要查看您构建的图像,那就是docker images。请查看docker user guide以获取有关运行docker的更多信息。

关于docker - 为什么docker-machine显示一个空列表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39070555/

回复

使用道具 举报

懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关注0

粉丝2

帖子830918

发布主题
阅读排行 更多
广告位

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap