-
Notifications
You must be signed in to change notification settings - Fork 1
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 |
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 | ||
- 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.** |
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
* | ||
*/ | ||
!.gitignore |
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 \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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} |
There was a problem hiding this comment.
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:
I am not sure how we can include this information in the readme. Do you have any suggestions?