How can I access my docker container in Heroku?

2019-07-12 03:29发布

问题:

I have followed the instructions on building an image here: https://devcenter.heroku.com/articles/container-registry-and-runtime#getting-started

I have successfully released my image to my heroku app and I do not know what to do next, to access my zsh command line and developing some stuff. I am trying to use ROS (Robot Operating System) in docker container on Heroku.

This is my Dockerfile:

FROM osrf/ros:kinetic-desktop-full
RUN apt-get update && apt-get install -y \
            locales \
        tmux \
        zsh \
        curl \
        wget \
        vim \
        emacs24 \
        sudo \
        libgl1-mesa-glx \
        libgl1-mesa-dri \
        mesa-utils \
        unzip \
        && rm -rf /var/likb/apt/lists/*
RUN locale-gen en_US.UTF-8
ENV LANG en_US.UTF-8
CMD ["zsh"]

As you can see, I am just installing ROS and basic packages together with zsh command line. This is what I have uploaded to Heroku using their instructions.

Now, on my local PC, I just run this scrip to make my container active and access zsh command line and developing my ROS further (as I would do using a usual bash line):

#! /bin/bash

xhost +local:
docker run -it --net=host \
--user=$(id -u) \
-e DISPLAY=$DISPLAY \
-e QT_GRAPHICSSYSTEM=native \
-e CONTAINER_NAME=ros-kinetic-dev \
-e USER=$USER \
--workdir=/home/$USER \
-v "/tmp/.X11-unix:/tmp/.X11-unix" \
-v "/etc/group:/etc/group:ro" \
-v "/etc/passwd:/etc/passwd:ro" \
-v "/etc/shadow:/etc/shadow:ro" \
-v "/etc/sudoers.d:/etc/sudoers.d:ro" \
-v "/home/$USER/:/home/$USER/" \
--device=/dev/dri:/dev/dri \
--name=ros-kinetic-dev \
kinetic:dev

To be short, I am also enabling the GUI to see some visualization like RViz, as ROS is heavily dependent on Qt.

So, can you help me on how can I access the same zsh command line on heroku (using my pushed image)?

回答1:

You can find desired container-ID through the following command:

$ docker ps

Then you can access to the container using:

$ docker exec -it <desired-container-ID> bash