Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dockerfile #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
FROM osrf/ros2:devel-bionic

ENV NO_AT_BRIDGE 1
ENV DEBIAN_FRONTEND noninteractive

RUN apt-get update > /dev/null 2>&1

# Install minimum configuration for any image
RUN apt-get install -y \
apt-utils \
bash-completion \
git \
ssh-client \
sudo \
terminator \
x11-apps

# Add new sudo user for using X server
ENV USERNAME docker
RUN useradd -m $USERNAME && \
echo "$USERNAME:$USERNAME" | chpasswd && \
usermod --shell /bin/bash $USERNAME && \
usermod -aG sudo $USERNAME && \
echo "$USERNAME ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers.d/$USERNAME && \
chmod 0440 /etc/sudoers.d/$USERNAME && \
# Replace 1000 with your user/group id
usermod --uid 1000 $USERNAME && \
groupmod --gid 1000 $USERNAME

USER docker

WORKDIR /home/docker
107 changes: 47 additions & 60 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,61 +1,48 @@
# DockerIt
Use Docker containers for tests and code validation!
# docker_bir
This repository provides a minimum template configuration so that the container's user home folder is mirrored in the host, making its files persistent.

---
## Usage

1. Clone (or download) this repository:
```
git clone [email protected]:Brazilian-Institute-of-Robotics/docker_bir.git
```
2. Adapt `Dockerfile` to your needs.
In this example, configuration was set up to work with ROS2 Foxy. You
may want to rename the image in both `Dockerfile` and `run-devel.bash`.

1. Run `run-devel.bash` (make sure it has execute permission):

```
chmod +x run-devel.bash
./run-devel.bash
```

The `home` folder of this repository will mirror and persist all the data of the container's home folder.

---
## Tip

It might be helpful to have a terminal gathering all relevant information for the docker user such as the images, the running, and the stopped containers.

For that, add the
following to your host's `~/.bash_aliases`:

```
alias docker_status='echo === IMAGES =============== && docker images && echo && \
echo === RUNNING CONTAINERS === && docker ps && echo && \
echo === ALL CONTAINERS ======= && docker ps -a'
alias docker_monitor='while true; clear; do docker_status; sleep 5; done'
```
Then:
```
source ~/.bash_aliases
docker_monitor
```

---
## References
- http://wiki.ros.org/docker/Tutorials/GUI

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could be helpful for newcomers to have a link to docker commands in this documentation so that they know at least those ones:

Command Description
docker rm Remove one or more containers
docker rmi Remove one or more images

I am not sure how we can include this information in the readme. Do you have any suggestions?

- https://docs.docker.com/engine/reference/commandline/docker/

![Screenshot from 2019-09-30 12-51-31](https://user-images.githubusercontent.com/32513366/65895032-24407080-e381-11e9-9f9e-8212fde3ca4f.png)

Useful docker images for robotic projects: https://hub.docker.com/u/bircimatec

## Install Docker
``
$ sudo apt-get install docker.io
``

## Docker basic commands
- Build a *Dockerfile*

``
$ docker build -t bircimatec/name:tag .
``

- Kill a container

``
$ docker kill containerName
``

- List all images in your computer

``
$ docker image ls
``

- List all containers running in your computer

``
$ docker container ls
``

- Erase all stopped containers

``
$ docker container prune
``


## Save your images into BIR DockerHub
- First, you need to get acess to [link](https://hub.docker.com/u/bircimatec). For this, you need to talk to *Gustavo Rezende*.
- After getting acess and built your image, follow the instructions:

(1) Login in your Docker Account through terminal

``
$ docker login --username=yourUserNameInDockerHub
``

(2) Push to docker hub repository

``
$ docker push bircimatec/name:tag
``

**(!) Delete *.json* file after your push for password security.**
7 changes: 0 additions & 7 deletions gazebo-ros/ubuntu/bionic/melodic/libgazebo9-nvidia/Dockerfile

This file was deleted.

29 changes: 0 additions & 29 deletions gazebo-ros/ubuntu/bionic/melodic/libgazebo9-nvidia/README.md

This file was deleted.

36 changes: 0 additions & 36 deletions gazebo-ros/ubuntu/bionic/melodic/libgazebo9/Dockerfile

This file was deleted.

5 changes: 0 additions & 5 deletions gazebo-ros/ubuntu/bionic/melodic/libgazebo9/README.md

This file was deleted.

7 changes: 0 additions & 7 deletions gazebo-ros/ubuntu/bionic/melodic/libgazebo9/entrypoint.sh

This file was deleted.

7 changes: 0 additions & 7 deletions gazebo-ros/ubuntu/xenial/kinetic/libgazebo7-nvidia/Dockerfile

This file was deleted.

47 changes: 0 additions & 47 deletions gazebo-ros/ubuntu/xenial/kinetic/libgazebo7-nvidia/README.md

This file was deleted.

52 changes: 0 additions & 52 deletions gazebo-ros/ubuntu/xenial/kinetic/libgazebo7/Dockerfile

This file was deleted.

20 changes: 0 additions & 20 deletions gazebo-ros/ubuntu/xenial/kinetic/libgazebo7/README.md

This file was deleted.

7 changes: 0 additions & 7 deletions gazebo-ros/ubuntu/xenial/kinetic/libgazebo7/entrypoint.sh

This file was deleted.

3 changes: 3 additions & 0 deletions home/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*
*/
!.gitignore
22 changes: 22 additions & 0 deletions run-devel.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

IMAGE=devel-foxy

# X Server configuration
XSOCK=/tmp/.X11-unix
XAUTH=/tmp/.docker.xauth
touch ${XAUTH}
xauth nlist ${DISPLAY} | sed -e 's/^..../ffff/' | xauth -f ${XAUTH} nmerge -

docker build -f Dockerfile -t ${IMAGE} .

docker run -it \
--rm \
--volume $(pwd)/home:/home/docker \

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@brschettini , this part defines folder persistency (the map between host and container folders).

--user=docker \
--privileged \
--volume=${XSOCK}:${XSOCK}:rw \
--volume=${XAUTH}:${XAUTH}:rw \
--env="XAUTHORITY=${XAUTH}" \
--env="DISPLAY" \
--name ${IMAGE}-container ${IMAGE}