2015-12-10 20 views
5

Nuovo nella finestra mobile su mac osx. Sto costruendo un'immagine ubuntu dall'immagine phusion di base da usare come server git. Utilizzando il seguente file per installare la base e il software necessario. Funziona alla grande Tuttavia, non riesco a eseguire il ping della macchina.Impossibile eseguire il ping del contenitore di finestre mobili

EDIT


non sono in grado di eseguire il ping della macchina. Posso eseguire l'immagine e vedere il contenitore nel comando ps. Posso anche eseguirmi bash in esso.

CONTAINER ID  IMAGE    COMMAND    CREATED    STATUS    PORTS    NAMES 
54e4cef78445  git-ssh_img   "/usr/sbin/sshd -D" 44 minutes ago  Up 44 minutes  22/tcp    git-ssh 

Di seguito lavora anche

docker exec -it 54e4cef78445 ping www.google.com 
PING www.google.com (173.194.219.147) 56(84) bytes of data. 
64 bytes from ya-in-f147.1e100.net (173.194.219.147): icmp_seq=1 ttl=61 time=65.1 ms 
64 bytes from ya-in-f147.1e100.net (173.194.219.147): icmp_seq=2 ttl=61 time=67.1 ms 

Dockerfile:

# Use phusion/baseimage as base image. To make your builds reproducible, make 
# sure you lock down to a specific version, not to `latest`! 
# See https://github.com/phusion/baseimage-docker/blob/master/Changelog.md for 
# a list of version numbers. 
FROM phusion/baseimage:0.9.18 

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

# ...put your own build instructions here... 

ENV TERM xterm 

RUN apt-get -y update 
RUN apt-get -y install openssh-server 
RUN apt-get -y install git \ 
    libxml2-dev \ 
    python \ 
    build-essential \ 
    make \ 
    gcc \ 
    python-dev \ 
    python-pip 

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

# Setting openssh 
# RUN mkdir /var/run/sshd 
RUN sed -i "s/#PasswordAuthentication yes/PasswordAuthentication no/" /etc/ssh/sshd_config 

# Adding git user 
RUN adduser --system git 
RUN mkdir -p /home/git/.ssh 

# Clearing and setting authorized ssh keys 
RUN echo '' > /home/git/.ssh/authorized_keys 
RUN echo 'First key' >> /home/git/.ssh/authorized_keys 
# RUN echo 'Second SSH public key' >> /home/git/.ssh/authorized_keys 
# ... 

# Updating shell to bash 
RUN sed -i s#/home/git:/bin/false#/home/git:/bin/bash# /etc/passwd 

EXPOSE 22 
CMD ["/usr/sbin/sshd", "-D"] 

Ispezionare comando:

[ 
{ 
    "Id": "54e4cef78445e1308b744297edc1d3d153932ce7724e87b35dc3690f8ffe41a2", 
    "Created": "2015-12-10T21:01:16.683875853Z", 
    "Path": "/usr/sbin/sshd", 
    "Args": [ 
     "-D" 
    ], 
    "State": { 
     "Running": true, 
     "Paused": false, 
     "Restarting": false, 
     "OOMKilled": false, 
     "Dead": false, 
     "Pid": 13930, 
     "ExitCode": 0, 
     "Error": "", 
     "StartedAt": "2015-12-10T21:01:16.763739339Z", 
     "FinishedAt": "0001-01-01T00:00:00Z" 
    }, 
    "Image": "b2c6f9604ceca1e112dc0560aa4d0c50596d27c80256c544613f1d6badf6ccda", 
    "NetworkSettings": { 
     "Bridge": "", 
     "EndpointID": "87f12f9b527f3e0d7f823f1e2c88b0d0e860ff2d1687568d0a15cfa9fdfe22c3", 
     "Gateway": "172.17.42.1", 
     "GlobalIPv6Address": "", 
     "GlobalIPv6PrefixLen": 0, 
     "HairpinMode": false, 
     "IPAddress": "172.17.0.26", 
     "IPPrefixLen": 16, 
     "IPv6Gateway": "", 
     "LinkLocalIPv6Address": "", 
     "LinkLocalIPv6PrefixLen": 0, 
     "MacAddress": "02:42:ac:11:00:1a", 
     "NetworkID": "a60ea78a8239baed013f9bfb1b2719a599ddef7745170e3c17eeab743a391ebe", 
     "PortMapping": null, 
     "Ports": { 
      "22/tcp": null 
     }, 
     "SandboxKey": "/var/run/docker/netns/54e4cef78445", 
     "SecondaryIPAddresses": null, 
     "SecondaryIPv6Addresses": null 
    }, 
    "ResolvConfPath": "/mnt/sda1/var/lib/docker/containers/54e4cef78445e1308b744297edc1d3d153932ce7724e87b35dc3690f8ffe41a2/resolv.conf", 
    "HostnamePath": "/mnt/sda1/var/lib/docker/containers/54e4cef78445e1308b744297edc1d3d153932ce7724e87b35dc3690f8ffe41a2/hostname", 
    "HostsPath": "/mnt/sda1/var/lib/docker/containers/54e4cef78445e1308b744297edc1d3d153932ce7724e87b35dc3690f8ffe41a2/hosts", 
    "LogPath": "/mnt/sda1/var/lib/docker/containers/54e4cef78445e1308b744297edc1d3d153932ce7724e87b35dc3690f8ffe41a2/54e4cef78445e1308b744297edc1d3d153932ce7724e87b35dc3690f8ffe41a2-json.log", 
    "Name": "/git-ssh", 
    "RestartCount": 0, 
    "Driver": "aufs", 
    "ExecDriver": "native-0.2", 
    "MountLabel": "", 
    "ProcessLabel": "", 
    "AppArmorProfile": "", 
    "ExecIDs": null, 
    "HostConfig": { 
     "Binds": null, 
     "ContainerIDFile": "", 
     "LxcConf": [], 
     "Memory": 0, 
     "MemorySwap": 0, 
     "CpuShares": 0, 
     "CpuPeriod": 0, 
     "CpusetCpus": "", 
     "CpusetMems": "", 
     "CpuQuota": 0, 
     "BlkioWeight": 0, 
     "OomKillDisable": false, 
     "MemorySwappiness": -1, 
     "Privileged": false, 
     "PortBindings": {}, 
     "Links": null, 
     "PublishAllPorts": false, 
     "Dns": null, 
     "DnsSearch": null, 
     "ExtraHosts": null, 
     "VolumesFrom": null, 
     "Devices": [], 
     "NetworkMode": "default", 
     "IpcMode": "", 
     "PidMode": "", 
     "UTSMode": "", 
     "CapAdd": null, 
     "CapDrop": null, 
     "GroupAdd": null, 
     "RestartPolicy": { 
      "Name": "no", 
      "MaximumRetryCount": 0 
     }, 
     "SecurityOpt": null, 
     "ReadonlyRootfs": false, 
     "Ulimits": null, 
     "LogConfig": { 
      "Type": "json-file", 
      "Config": {} 
     }, 
     "CgroupParent": "", 
     "ConsoleSize": [ 
      0, 
      0 
     ] 
    }, 
    "GraphDriver": { 
     "Name": "aufs", 
     "Data": null 
    }, 
    "Mounts": [], 
    "Config": { 
     "Hostname": "54e4cef78445", 
     "Domainname": "", 
     "User": "", 
     "AttachStdin": false, 
     "AttachStdout": true, 
     "AttachStderr": true, 
     "ExposedPorts": { 
      "22/tcp": {} 
     }, 
     "Tty": false, 
     "OpenStdin": false, 
     "StdinOnce": false, 
     "Env": [ 
      "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", 
      "TERM=xterm" 
     ], 
     "Cmd": [ 
      "/usr/sbin/sshd", 
      "-D" 
     ], 
     "Image": "git-ssh_img", 
     "Volumes": null, 
     "WorkingDir": "", 
     "Entrypoint": null, 
     "OnBuild": null, 
     "Labels": {} 
    } 
} 
] 
+0

Non sono chiaro sulla domanda. Cosa stai cercando di eseguire il ping, il contenitore o l'host su cui è in esecuzione il container? Il primo è possibile solo sullo stesso host che esegue il contenitore. –

+0

@AndyShinn che prova a ssh nel contenitore dall'host. Quindi l'idea è di aggiungere un contenitore come origine remota git e utilizzarlo come git server. Stavo per metterlo su bluemix/amazon cloud come immagine docker. Attualmente, quando I "git remote add" dall'host, scade. Forse non pensando correttamente alla finestra mobile qui :(. –

+0

Questo è abbastanza giusto, ma ci sono alcune cose importanti che mancano alla tua domanda.Come era il comando Docker utilizzato per avviare il contenitore demone SSH git? Qual è l'indirizzo IP dell'host Docker? comando che hai usato per aggiungere il git remote? –

risposta

3

Come menzionato in "Can't visit http://172.17.0.2:5000 after starting docker registry", non è possibile utilizzare l'IP interno creato per container-to-container communication.

È necessario utilizzare l'IP restituito da $(docker-machine ip <yourMachine>) per eseguire effettivamente il ping sulla macchina che esegue il contenitore.


Aggiornamento Febbraio 2017, finestra mobile 1.13+: come commented da kboom, ora avete Docker for Mac che usa un hypervisor leggero (HyperKit), che permette di essere vincolato a localhost (ma ancora non è possibile visitare gli indirizzi interni).

+0

Solo per notare - le cose sono cambiate un po 'da quando sono stati introdotti "Docker per Mac" o "Docker per Windows". Ora è legato a localhost stesso (ma ancora non puoi visitare gli indirizzi interni) – kboom

+0

@kboom Grazie. Ho incluso il tuo commento nella risposta per maggiore visibilità. – VonC

Problemi correlati