简体   繁体   English

即使连接到端口,也无法到达 docker 容器

[英]cannot reach docker container even its connected to a port

ı am trying to use a container and I came across a problem.我正在尝试使用容器,但遇到了问题。 when I curl localhost:8000 inside the container it connects but when I try to go there it says unable to connect.当我 curl localhost:8000 在它连接的容器内时,但是当我尝试 go 时,它说无法连接。 I am providing a screenshot, my YAML file, and my dockerfile.devel in case that helps.我提供了一个屏幕截图、我的 YAML 文件和我的 dockerfile.devel 以防万一。 Thanks already.已经谢谢了。 i curled inside the container and it connected to the port我蜷缩在容器内,它连接到端口

my yaml file我的 yaml 文件

version: "2"

services:
  cuckoo:
    privileged: true
    image: cuckoo-docker:2.0.7
    build:
      context: ./
      dockerfile: src/Dockerfile.devel
    ports:
      - "8888:8000"
      - "2042:2042"
    expose:
      - "8000"
    links:
      - mongo
      - postgres
    networks:
     - cuckoo
    restart: always
    cap_add:
      - NET_ADMIN
    extra_hosts:
      - "libvirt.local:172.30.201.1"

  mongo:
    image: mongo
    ports:
      - 27017:27017
    networks:
     - cuckoo
    restart: always

  postgres:
    image: postgres
    ports:
      - 5432:5432
    environment:
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: cuckoo
    networks:
     - cuckoo
    restart: always

networks:
  cuckoo:
    driver: bridge

my dockerfile.devel我的 dockerfile.devel

FROM ubuntu:18.04

ENV container docker
ENV LC_ALL C
ENV DEBIAN_FRONTEND noninteractive

RUN sed -i 's/# deb/deb/g' /etc/apt/sources.list

RUN apt update \
    && apt full-upgrade -y \
    && apt install -y systemd systemd-sysv \
    && apt clean \
    && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

RUN cd /lib/systemd/system/sysinit.target.wants/ \
    && ls | grep -v systemd-tmpfiles-setup | xargs rm -f $1

RUN rm -f /lib/systemd/system/multi-user.target.wants/* \
    /etc/systemd/system/*.wants/* \
    /lib/systemd/system/local-fs.target.wants/* \
    /lib/systemd/system/sockets.target.wants/*udev* \
    /lib/systemd/system/sockets.target.wants/*initctl* \
    /lib/systemd/system/basic.target.wants/* \
    /lib/systemd/system/anaconda.target.wants/* \
    /lib/systemd/system/plymouth* \
    /lib/systemd/system/systemd-update-utmp*

RUN apt update \
    && apt install -y python2.7 python-pip python-dev libffi-dev libssl-dev python-virtualenv python-setuptools libjpeg-dev zlib1g-dev swig qemu-kvm libvirt-bin \
    ubuntu-vm-builder bridge-utils python-libvirt tcpdump libguac-client-rdp0 libguac-client-vnc0 libguac-client-ssh0 guacd pcregrep libpcre++-dev autoconf automake libtool \
    build-essential libjansson-dev libmagic-dev supervisor mongodb postgresql postgresql-contrib libpq-dev nano bison byacc tor suricata flex\
    && apt clean

RUN set -x \
    && cd /tmp/ \
    && git clone --recursive --branch 'v3.11.0' https://github.com/VirusTotal/yara.git \
    && cd /tmp/yara \
    && ./bootstrap.sh * \
    && sync \
    && ./configure --with-crypto --enable-magic --enable-cuckoo --enable-dotnet \
    && make \
    && make install \
    && rm -rf /tmp/* \
    && cd /tmp \
    && git clone --recursive --branch '2.6.1' https://github.com/volatilityfoundation/volatility.git \
    && cd volatility \
    && python setup.py build install \
    && rm -rf /tmp/*


RUN pip install -U --no-cache-dir pyrsistent==0.16.1 MarkupSafe==1.1.1 itsdangerous==1.1.0 configparser==4.0.2 distorm3==3.4.4 setuptools pycrypto ujson  cryptography psycopg2 jsonschema==3.2.0 werkzeug==0.16.0 Mako==1.1.0 python-editor==1.0.3 urllib3==1.25.7 tlslite==0.4.9 SFlock==0.3.3 tlslite-ng==0.7.6 pyOpenSSL==18.0.0

  

RUN apt update && apt install -y vim
COPY cuckoo /opt/cuckoo
WORKDIR /opt/cuckoo
RUN python stuff/monitor.py
RUN python setup.py sdist develop
RUN cuckoo init
RUN cuckoo community


COPY etc/conf /root/.cuckoo/conf
COPY etc/supervisord.conf /root/.cuckoo/
COPY etc/cuckoo.sh /opt/

RUN chmod +x /opt/cuckoo.sh

CMD ["/opt/cuckoo.sh"]

When you set当你设置

    ports:
      - "8888:8000"

this means that the port 8000 in the container is mapped to the port 8888 in the host machine so if you curl from the host machine you have to curl port 8888这意味着容器中的端口 8000映射到主机中的端口 8888所以如果你从主机 curl 你必须 curl 端口 8888

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM