Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/docker/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Docker新手,这个图像创建成功了吗?_Docker - Fatal编程技术网

Docker新手,这个图像创建成功了吗?

Docker新手,这个图像创建成功了吗?,docker,Docker,运行docker build.输出: Sending build context to Docker daemon 2.048 kB Step 1 : FROM ubuntu:14.04.3 14.04.3: Pulling from library/ubuntu 8387d9ff0016: Pull complete 3b52deaaf0ed: Pull complete 4bd501fad6de: Pull complete a3ed95caeb02: Pull complete D

运行
docker build.
输出:

Sending build context to Docker daemon 2.048 kB
Step 1 : FROM ubuntu:14.04.3
14.04.3: Pulling from library/ubuntu
8387d9ff0016: Pull complete 
3b52deaaf0ed: Pull complete 
4bd501fad6de: Pull complete 
a3ed95caeb02: Pull complete 
Digest: sha256:2febbcede4f3eb82ae0dc44518a2e2a7b06a0452685e64e6b13f51b278294780
Status: Downloaded newer image for ubuntu:14.04.3
 ---> 3876b81b5a81
Step 2 : RUN sudo apt-get install git
 ---> Running in cda85e00be34
Reading package lists...
Building dependency tree...
Reading state information...
The following extra packages will be installed:
  ca-certificates git-man krb5-locales libasn1-8-heimdal libcurl3-gnutls
  libedit2 liberror-perl libgssapi-krb5-2 libgssapi3-heimdal
  libhcrypto4-heimdal libheimbase1-heimdal libheimntlm0-heimdal
  libhx509-5-heimdal libidn11 libk5crypto3 libkeyutils1 libkrb5-26-heimdal
  libkrb5-3 libkrb5support0 libldap-2.4-2 libroken18-heimdal librtmp0
  libsasl2-2 libsasl2-modules libsasl2-modules-db libwind0-heimdal libx11-6
  libx11-data libxau6 libxcb1 libxdmcp6 libxext6 libxmuu1 openssh-client
  openssl patch rsync xauth
Suggested packages:
  gettext-base git-daemon-run git-daemon-sysvinit git-doc git-el git-email
  git-gui gitk gitweb git-arch git-bzr git-cvs git-mediawiki git-svn krb5-doc
  krb5-user libsasl2-modules-otp libsasl2-modules-ldap libsasl2-modules-sql
  libsasl2-modules-gssapi-mit libsasl2-modules-gssapi-heimdal ssh-askpass
  libpam-ssh keychain monkeysphere ed diffutils-doc openssh-server
Recommended packages:
  ssh-client
The following NEW packages will be installed:
  ca-certificates git git-man krb5-locales libasn1-8-heimdal libcurl3-gnutls
  libedit2 liberror-perl libgssapi-krb5-2 libgssapi3-heimdal
  libhcrypto4-heimdal libheimbase1-heimdal libheimntlm0-heimdal
  libhx509-5-heimdal libidn11 libk5crypto3 libkeyutils1 libkrb5-26-heimdal
  libkrb5-3 libkrb5support0 libldap-2.4-2 libroken18-heimdal librtmp0
  libsasl2-2 libsasl2-modules libsasl2-modules-db libwind0-heimdal libx11-6
  libx11-data libxau6 libxcb1 libxdmcp6 libxext6 libxmuu1 openssh-client
  openssl patch rsync xauth
0 upgraded, 39 newly installed, 0 to remove and 0 not upgraded.
Need to get 7671 kB of archives.
After this operation, 41.2 MB of additional disk space will be used.
Do you want to continue? [Y/n] Abort.
The command '/bin/sh -c sudo apt-get install git' returned a non-zero code: 1

ssh user@ .com
MACLA910275:~ user$ ssh user@ .com

Unauthorized access to or use of this system is prohibited.
All access and use may be monitored and recorded.

user@ .com's password: 
Welcome to Ubuntu 14.04.3 LTS (GNU/Linux 3.19.0-39-generic x86_64)

Unauthorized access to or use of this system is prohibited. All access and use may be monitored and recorded.
Unauthorized access to or use of this system is prohibited. All access and use may be monitored and recorded.
user@ :~$ ls
user@ :~$ pwd
/home/user
user@ :~$ sudo apt-get install git
Reading package lists... Done
Building dependency tree       
Reading state information... Done
git is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 66 not upgraded.
user@ :~$ docker
Usage: docker [OPTIONS] COMMAND [arg...]
       docker daemon [ --help | ... ]
       docker [ --help | -v | --version ]

A self-sufficient runtime for containers.

Options:

  --config=~/.docker              Location of client config files
  -D, --debug                     Enable debug mode
  -H, --host=[]                   Daemon socket(s) to connect to
  -h, --help                      Print usage
  -l, --log-level=info            Set the logging level
  --tls                           Use TLS; implied by --tlsverify
  --tlscacert=~/.docker/ca.pem    Trust certs signed only by this CA
  --tlscert=~/.docker/cert.pem    Path to TLS certificate file
  --tlskey=~/.docker/key.pem      Path to TLS key file
  --tlsverify                     Use TLS and verify the remote
  -v, --version                   Print version information and quit

Commands:
    attach    Attach to a running container
    build     Build an image from a Dockerfile
    commit    Create a new image from a container's changes
    cp        Copy files/folders between a container and the local filesystem
    create    Create a new container
    diff      Inspect changes on a container's filesystem
    events    Get real time events from the server
    exec      Run a command in a running container
    export    Export a container's filesystem as a tar archive
    history   Show the history of an image
    images    List images
    import    Import the contents from a tarball to create a filesystem image
    info      Display system-wide information
    inspect   Return low-level information on a container or image
    kill      Kill a running container
    load      Load an image from a tar archive or STDIN
    login     Log in to a Docker registry
    logout    Log out from a Docker registry
    logs      Fetch the logs of a container
    network   Manage Docker networks
    pause     Pause all processes within a container
    port      List port mappings or a specific mapping for the CONTAINER
    ps        List containers
    pull      Pull an image or a repository from a registry
    push      Push an image or a repository to a registry
    rename    Rename a container
    restart   Restart a container
    rm        Remove one or more containers
    rmi       Remove one or more images
    run       Run a command in a new container
    save      Save one or more images to a tar archive
    search    Search the Docker Hub for images
    start     Start one or more stopped containers
    stats     Display a live stream of container(s) resource usage statistics
    stop      Stop a running container
    tag       Tag an image into a repository
    top       Display the running processes of a container
    unpause   Unpause all processes within a container
    update    Update configuration of one or more containers
    version   Show the Docker version information
    volume    Manage Docker volumes
    wait      Block until a container stops, then print its exit code

Run 'docker COMMAND --help' for more information on a command.
user@ :~$ sudo apt-get install g
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package g
user@ :~$ 
user@ :~$ 
user@ :~$ 
user@ :~$ 
user@ :~$ 
user@ :~$ docker images
Cannot connect to the Docker daemon. Is the docker daemon running on this host?
user@ :~$ docker version
Client:
 Version:      1.11.2
 API version:  1.23
 Go version:   go1.5.4
 Git commit:   b9f10c9
 Built:        Wed Jun  1 21:47:50 2016
 OS/Arch:      linux/amd64
Cannot connect to the Docker daemon. Is the docker daemon running on this host?
user@ :~$ sudo -i
root@ :~# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
hello-world         latest              693bce725149        3 weeks ago         967 B
root@ :~# \
> 
root@ :~# 
root@ :~# 
root@ :~# 
root@ :~# 
root@ :~# 
root@ :~# DOCKER PS -a
DOCKER: command not found
root@ :~# docker ps -1
flag provided but not defined: -1
See 'docker ps --help'.
root@ :~# docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                  PORTS               NAMES
4e22edd9df8a        hello-world         "/hello"            2 days ago          Exited (0) 2 days ago                       big_boyd
root@ :~# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 14.04.3 LTS
Release:    14.04
Codename:   trusty
root@ :~# pwd
/root
root@ :~# mkdir docker-myproject
root@ :~# cd docker-myproject/
root@ :~/docker-myproject# ls
root@ :~/docker-myproject# vi Dockerfile
root@ :~/docker-myproject# vi Dockerfile
root@ :~/docker-myproject# vi Dockerfile
root@ :~/docker-myproject# vi Dockerfile
root@ :~/docker-myproject# vi Dockerfile
root@ :~/docker-myproject# vi Dockerfile
root@ :~/docker-myproject# 
root@ :~/docker-myproject# 
root@ :~/docker-myproject# docker build .
Sending build context to Docker daemon 2.048 kB
Step 1 : FROM ubuntu 14.04.3
Error parsing reference: "ubuntu 14.04.3" is not a valid repository/tag
root@ :~/docker-myproject# vi Dockerfile
root@ :~/docker-myproject# 
root@ :~/docker-myproject# 
root@ :~/docker-myproject# docker build .
Sending build context to Docker daemon 2.048 kB
Step 1 : FROM ubuntu:14.04.3
14.04.3: Pulling from library/ubuntu
8387d9ff0016: Pull complete 
3b52deaaf0ed: Pull complete 
4bd501fad6de: Pull complete 
a3ed95caeb02: Pull complete 
Digest: sha256:2febbcede4f3eb82ae0dc44518a2e2a7b06a0452685e64e6b13f51b278294780
Status: Downloaded newer image for ubuntu:14.04.3
 ---> 3876b81b5a81
Step 2 : RUN sudo apt-get install git
 ---> Running in cda85e00be34
Reading package lists...
Building dependency tree...
Reading state information...
The following extra packages will be installed:
  ca-certificates git-man krb5-locales libasn1-8-heimdal libcurl3-gnutls
  libedit2 liberror-perl libgssapi-krb5-2 libgssapi3-heimdal
  libhcrypto4-heimdal libheimbase1-heimdal libheimntlm0-heimdal
  libhx509-5-heimdal libidn11 libk5crypto3 libkeyutils1 libkrb5-26-heimdal
  libkrb5-3 libkrb5support0 libldap-2.4-2 libroken18-heimdal librtmp0
  libsasl2-2 libsasl2-modules libsasl2-modules-db libwind0-heimdal libx11-6
  libx11-data libxau6 libxcb1 libxdmcp6 libxext6 libxmuu1 openssh-client
  openssl patch rsync xauth
Suggested packages:
  gettext-base git-daemon-run git-daemon-sysvinit git-doc git-el git-email
  git-gui gitk gitweb git-arch git-bzr git-cvs git-mediawiki git-svn krb5-doc
  krb5-user libsasl2-modules-otp libsasl2-modules-ldap libsasl2-modules-sql
  libsasl2-modules-gssapi-mit libsasl2-modules-gssapi-heimdal ssh-askpass
  libpam-ssh keychain monkeysphere ed diffutils-doc openssh-server
Recommended packages:
  ssh-client
The following NEW packages will be installed:
  ca-certificates git git-man krb5-locales libasn1-8-heimdal libcurl3-gnutls
  libedit2 liberror-perl libgssapi-krb5-2 libgssapi3-heimdal
  libhcrypto4-heimdal libheimbase1-heimdal libheimntlm0-heimdal
  libhx509-5-heimdal libidn11 libk5crypto3 libkeyutils1 libkrb5-26-heimdal
  libkrb5-3 libkrb5support0 libldap-2.4-2 libroken18-heimdal librtmp0
  libsasl2-2 libsasl2-modules libsasl2-modules-db libwind0-heimdal libx11-6
  libx11-data libxau6 libxcb1 libxdmcp6 libxext6 libxmuu1 openssh-client
  openssl patch rsync xauth
0 upgraded, 39 newly installed, 0 to remove and 0 not upgraded.
Need to get 7671 kB of archives.
After this operation, 41.2 MB of additional disk space will be used.
Do you want to continue? [Y/n] Abort.
The command '/bin/sh -c sudo apt-get install git' returned a non-zero code: 1
root@ :~/docker-myproject# docker build .
Sending build context to Docker daemon 2.048 kB
Step 1 : FROM ubuntu:14.04.3
 ---> 3876b81b5a81
Step 2 : RUN sudo apt-get install git
 ---> Running in 1de93513f856
Reading package lists...
Building dependency tree...
Reading state information...
The following extra packages will be installed:
  ca-certificates git-man krb5-locales libasn1-8-heimdal libcurl3-gnutls
  libedit2 liberror-perl libgssapi-krb5-2 libgssapi3-heimdal
  libhcrypto4-heimdal libheimbase1-heimdal libheimntlm0-heimdal
  libhx509-5-heimdal libidn11 libk5crypto3 libkeyutils1 libkrb5-26-heimdal
  libkrb5-3 libkrb5support0 libldap-2.4-2 libroken18-heimdal librtmp0
  libsasl2-2 libsasl2-modules libsasl2-modules-db libwind0-heimdal libx11-6
  libx11-data libxau6 libxcb1 libxdmcp6 libxext6 libxmuu1 openssh-client
  openssl patch rsync xauth
Suggested packages:
  gettext-base git-daemon-run git-daemon-sysvinit git-doc git-el git-email
  git-gui gitk gitweb git-arch git-bzr git-cvs git-mediawiki git-svn krb5-doc
  krb5-user libsasl2-modules-otp libsasl2-modules-ldap libsasl2-modules-sql
  libsasl2-modules-gssapi-mit libsasl2-modules-gssapi-heimdal ssh-askpass
  libpam-ssh keychain monkeysphere ed diffutils-doc openssh-server
Recommended packages:
  ssh-client
The following NEW packages will be installed:
  ca-certificates git git-man krb5-locales libasn1-8-heimdal libcurl3-gnutls
  libedit2 liberror-perl libgssapi-krb5-2 libgssapi3-heimdal
  libhcrypto4-heimdal libheimbase1-heimdal libheimntlm0-heimdal
  libhx509-5-heimdal libidn11 libk5crypto3 libkeyutils1 libkrb5-26-heimdal
  libkrb5-3 libkrb5support0 libldap-2.4-2 libroken18-heimdal librtmp0
  libsasl2-2 libsasl2-modules libsasl2-modules-db libwind0-heimdal libx11-6
  libx11-data libxau6 libxcb1 libxdmcp6 libxext6 libxmuu1 openssh-client
  openssl patch rsync xauth
0 upgraded, 39 newly installed, 0 to remove and 0 not upgraded.
Need to get 7671 kB of archives.
After this operation, 41.2 MB of additional disk space will be used.
Do you want to continue? [Y/n] Abort.
The command '/bin/sh -c sudo apt-get install git' returned a non-zero code: 1
root@ :~/docker-myproject# git
usage: git [--version] [--help] [-C <path>] [-c name=value]
           [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
           [-p|--paginate|--no-pager] [--no-replace-objects] [--bare]
           [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
           <command> [<args>]

The most commonly used git commands are:
   add        Add file contents to the index
   bisect     Find by binary search the change that introduced a bug
   branch     List, create, or delete branches
   checkout   Checkout a branch or paths to the working tree
   clone      Clone a repository into a new directory
   commit     Record changes to the repository
   diff       Show changes between commits, commit and working tree, etc
   fetch      Download objects and refs from another repository
   grep       Print lines matching a pattern
   init       Create an empty Git repository or reinitialize an existing one
   log        Show commit logs
   merge      Join two or more development histories together
   mv         Move or rename a file, a directory, or a symlink
   pull       Fetch from and integrate with another repository or a local branch
   push       Update remote refs along with associated objects
   rebase     Forward-port local commits to the updated upstream head
   reset      Reset current HEAD to the specified state
   rm         Remove files from the working tree and from the index
   show       Show various types of objects
   status     Show the working tree status
   tag        Create, list, delete or verify a tag object signed with GPG

'git help -a' and 'git help -g' lists available subcommands and some
concept guides. See 'git help <command>' or 'git help <concept>'
to read about a specific subcommand or concept.
root@ :~/docker-myproject# ls
Dockerfile
root@ :~/docker-myproject# vi Dockerfile 
docker图像返回:

ubuntu              14.04.3             3876b81b5a81        5 months ago        187.9 MB
图像是新创建的,但显示为“5个月前”创建的,这是否表明是今天创建的

既然已经安装了git,那么是什么导致了此错误?:

After this operation, 41.2 MB of additional disk space will be used.
Do you want to continue? [Y/n] Abort.
The command '/bin/sh -c sudo apt-get install git' returned a non-zero code: 1
  • 默认情况下,如果APT将要安装一组总大小超过某个值的软件包,它将在安装前要求您确认。但是,构建Docker映像时运行的命令都是非交互式的,因此,
    apt get install git
    将无法获得其问题的答案,因此它将不做任何操作而退出。您需要在Dockerfile中使用apt get install-y git,以便自动对提示说“是”。(请注意,
    sudo
    在这里是多余的,因为该命令已作为root用户运行。)

  • 由于Dockerfile在第一条指令中失败,
    docker build
    实际上没有创建新映像。docker images的输出显示您只有一个图像,
    ubuntu:14.04.3
    ,这是五个月前创建的图像

  • Git还没有“安装”,因为它没有出现在官方的
    ubuntu
    Docker图片中。Git是否安装在主机系统上与它是否安装在Docker映像中完全没有关系

  • 默认情况下,如果APT将要安装一组总大小超过某个值的软件包,它将在安装前要求您确认。但是,构建Docker映像时运行的命令都是非交互式的,因此,
    apt get install git
    将无法获得其问题的答案,因此它将不做任何操作而退出。您需要在Dockerfile中使用apt get install-y git,以便自动对提示说“是”。(请注意,
    sudo
    在这里是多余的,因为该命令已作为root用户运行。)

  • 由于Dockerfile在第一条指令中失败,
    docker build
    实际上没有创建新映像。docker images的输出显示您只有一个图像,
    ubuntu:14.04.3
    ,这是五个月前创建的图像

  • Git还没有“安装”,因为它没有出现在官方的
    ubuntu
    Docker图片中。Git是否安装在主机系统上与它是否安装在Docker映像中完全没有关系


  • 使用apt get install git-y(如果需要,使用
    sudo
    )重试git安装。这应该行。

    使用
    apt get install git-y
    重试git安装(如果需要,使用
    sudo
    )。这应该行。

    您不能在dockerfile中请求用户输入-使用apt get-y回答提示您不能在dockerfile中请求用户输入-使用apt get-y回答提示
    sudo
    不需要。
    sudo
    不需要。
    After this operation, 41.2 MB of additional disk space will be used.
    Do you want to continue? [Y/n] Abort.
    The command '/bin/sh -c sudo apt-get install git' returned a non-zero code: 1