cowrie/Dockerfile

58 lines
2.0 KiB
Docker
Raw Normal View History

FROM debian:stable-slim as python3-base
RUN apt-get update
RUN apt-get install --no-install-recommends -y libffi6 python3 python3-pip
RUN adduser --system --shell /bin/bash --group --disabled-password --no-create-home --home /cowrie cowrie
RUN mkdir -p /cowrie/var/lib/cowrie/downloads
RUN mkdir -p /cowrie/var/lib/cowrie/tty
RUN mkdir -p /cowrie/var/log/cowrie/
RUN chown -R cowrie:cowrie /cowrie
RUN chmod -R a+rX /cowrie
Full docker support (#830) * Full docker support Currently Docker images are build by a second git repository. Changes to installation or starting cowrie would need to be done on both. Merging this into one repository prevents that those will be forgotten and makes it easier to understand why changes happen. The dockerfile is a different one then the one from the docker-cowrie repository. I chose to use a python2-alpine linux. In the end this image has 55% smaller image size than the Debian image. The build process is split into to parts. The first image has everything installed to compile the python modules. The second one has only things installed which are needed to run the daemon. There is no need to install python-virtualenv because we are using docker. We don't need that much layers. Twisted can drop his privileges when starting the daemon when `--uid` and `--gid` is passed. This works only with numerical id. The user nobody is used for this. This is on Docker a good idea since there should be only one service with this user running. In other systems there might be several services using this daemon which is not a good choise. When building a new Docker image for cowrie Docker multistage build images are created running flake8 and unittests to ensure that all future releases are stable and matching our code guidelines. Bonus effect is when using this as a git pre-push-hook a developer doesn't need to wait for travis to fail on an error. Based on the current project structure we need a lot of `COPY` instructions inside the dockerfile which has negative sideeffects. - bloading the dockerfile up - longer buildtimes - more layers are created - more diskspace is used We should find a way to reduce this. Best way for doing this is keeping the static files like `honeyfs` and `share` right next to the source code. * Removing UID 0 check Cowrie checked on startup if it was started with root privileges. This conflicts with the option to let cowrie drop his privileges on startup using the twisted option `--uid` and `--gid`. I tested it a day ago without removing the code block and it run through but now it is for some reasons blocking. My feeling is that the code for droping privileges is also asynchron and sometimes the check is faster then the dropping of the privileges. But I might be wrong here. The solution is to remove the hole check. Considering that the check is there for preventing new users to shoot their feet we fixed this problem on different levels. New users should the docker images which are far easier to control and deploy then everything else because we take care. If a user wants to deploy it from scratch onto their serves there is a install instruction with detailed steps. This steps includes creating a special system user for cowrie and starting it with this user. * Fix missing directory, simplify path I missed to create the TTY log path. That's now fixed. Also the path for the trial command has been simplified. * Revert "Removing UID 0 check" This reverts commit f76329cd798744d10a0f52281e5a3588955d2531. * Introducint ENV var COWRIE_DOCKER The variable is used inside the docker image to let cowrie know that it is running inside docker and don't need to perform the "running as root" check. Inside the docker image cowrie is started with the `--uid` and `--gid` option and will drop to a different user then root. * Restructured Dockerfile, Added cowrie user The image is now builded with a user and group for running in the later image cowrie. Also the build steps are re-aranged to save build time. We assume that static files like `honeyfs` and `share` are less frequently updated and can be build into the base image where every other images is based on. * Renamed directory src -> cowrie The name cowrie should be more self-explaining then src. * Update cowrie_plugin.py
2018-08-06 08:27:32 +00:00
COPY requirements.txt .
COPY requirements-output.txt .
Full docker support (#830) * Full docker support Currently Docker images are build by a second git repository. Changes to installation or starting cowrie would need to be done on both. Merging this into one repository prevents that those will be forgotten and makes it easier to understand why changes happen. The dockerfile is a different one then the one from the docker-cowrie repository. I chose to use a python2-alpine linux. In the end this image has 55% smaller image size than the Debian image. The build process is split into to parts. The first image has everything installed to compile the python modules. The second one has only things installed which are needed to run the daemon. There is no need to install python-virtualenv because we are using docker. We don't need that much layers. Twisted can drop his privileges when starting the daemon when `--uid` and `--gid` is passed. This works only with numerical id. The user nobody is used for this. This is on Docker a good idea since there should be only one service with this user running. In other systems there might be several services using this daemon which is not a good choise. When building a new Docker image for cowrie Docker multistage build images are created running flake8 and unittests to ensure that all future releases are stable and matching our code guidelines. Bonus effect is when using this as a git pre-push-hook a developer doesn't need to wait for travis to fail on an error. Based on the current project structure we need a lot of `COPY` instructions inside the dockerfile which has negative sideeffects. - bloading the dockerfile up - longer buildtimes - more layers are created - more diskspace is used We should find a way to reduce this. Best way for doing this is keeping the static files like `honeyfs` and `share` right next to the source code. * Removing UID 0 check Cowrie checked on startup if it was started with root privileges. This conflicts with the option to let cowrie drop his privileges on startup using the twisted option `--uid` and `--gid`. I tested it a day ago without removing the code block and it run through but now it is for some reasons blocking. My feeling is that the code for droping privileges is also asynchron and sometimes the check is faster then the dropping of the privileges. But I might be wrong here. The solution is to remove the hole check. Considering that the check is there for preventing new users to shoot their feet we fixed this problem on different levels. New users should the docker images which are far easier to control and deploy then everything else because we take care. If a user wants to deploy it from scratch onto their serves there is a install instruction with detailed steps. This steps includes creating a special system user for cowrie and starting it with this user. * Fix missing directory, simplify path I missed to create the TTY log path. That's now fixed. Also the path for the trial command has been simplified. * Revert "Removing UID 0 check" This reverts commit f76329cd798744d10a0f52281e5a3588955d2531. * Introducint ENV var COWRIE_DOCKER The variable is used inside the docker image to let cowrie know that it is running inside docker and don't need to perform the "running as root" check. Inside the docker image cowrie is started with the `--uid` and `--gid` option and will drop to a different user then root. * Restructured Dockerfile, Added cowrie user The image is now builded with a user and group for running in the later image cowrie. Also the build steps are re-aranged to save build time. We assume that static files like `honeyfs` and `share` are less frequently updated and can be build into the base image where every other images is based on. * Renamed directory src -> cowrie The name cowrie should be more self-explaining then src. * Update cowrie_plugin.py
2018-08-06 08:27:32 +00:00
COPY honeyfs /cowrie/honeyfs
COPY share /cowrie/share
COPY etc /cowrie/etc
FROM python3-base as builder
RUN apt-get install --no-install-recommends -y python3-wheel python3-setuptools build-essential libssl-dev libffi-dev python3-dev libsnappy-dev default-libmysqlclient-dev
RUN pip3 wheel --wheel-dir=/root/wheelhouse -r requirements.txt
RUN pip3 wheel --wheel-dir=/root/wheelhouse -r requirements-output.txt
Full docker support (#830) * Full docker support Currently Docker images are build by a second git repository. Changes to installation or starting cowrie would need to be done on both. Merging this into one repository prevents that those will be forgotten and makes it easier to understand why changes happen. The dockerfile is a different one then the one from the docker-cowrie repository. I chose to use a python2-alpine linux. In the end this image has 55% smaller image size than the Debian image. The build process is split into to parts. The first image has everything installed to compile the python modules. The second one has only things installed which are needed to run the daemon. There is no need to install python-virtualenv because we are using docker. We don't need that much layers. Twisted can drop his privileges when starting the daemon when `--uid` and `--gid` is passed. This works only with numerical id. The user nobody is used for this. This is on Docker a good idea since there should be only one service with this user running. In other systems there might be several services using this daemon which is not a good choise. When building a new Docker image for cowrie Docker multistage build images are created running flake8 and unittests to ensure that all future releases are stable and matching our code guidelines. Bonus effect is when using this as a git pre-push-hook a developer doesn't need to wait for travis to fail on an error. Based on the current project structure we need a lot of `COPY` instructions inside the dockerfile which has negative sideeffects. - bloading the dockerfile up - longer buildtimes - more layers are created - more diskspace is used We should find a way to reduce this. Best way for doing this is keeping the static files like `honeyfs` and `share` right next to the source code. * Removing UID 0 check Cowrie checked on startup if it was started with root privileges. This conflicts with the option to let cowrie drop his privileges on startup using the twisted option `--uid` and `--gid`. I tested it a day ago without removing the code block and it run through but now it is for some reasons blocking. My feeling is that the code for droping privileges is also asynchron and sometimes the check is faster then the dropping of the privileges. But I might be wrong here. The solution is to remove the hole check. Considering that the check is there for preventing new users to shoot their feet we fixed this problem on different levels. New users should the docker images which are far easier to control and deploy then everything else because we take care. If a user wants to deploy it from scratch onto their serves there is a install instruction with detailed steps. This steps includes creating a special system user for cowrie and starting it with this user. * Fix missing directory, simplify path I missed to create the TTY log path. That's now fixed. Also the path for the trial command has been simplified. * Revert "Removing UID 0 check" This reverts commit f76329cd798744d10a0f52281e5a3588955d2531. * Introducint ENV var COWRIE_DOCKER The variable is used inside the docker image to let cowrie know that it is running inside docker and don't need to perform the "running as root" check. Inside the docker image cowrie is started with the `--uid` and `--gid` option and will drop to a different user then root. * Restructured Dockerfile, Added cowrie user The image is now builded with a user and group for running in the later image cowrie. Also the build steps are re-aranged to save build time. We assume that static files like `honeyfs` and `share` are less frequently updated and can be build into the base image where every other images is based on. * Renamed directory src -> cowrie The name cowrie should be more self-explaining then src. * Update cowrie_plugin.py
2018-08-06 08:27:32 +00:00
FROM python3-base as post-builder
Full docker support (#830) * Full docker support Currently Docker images are build by a second git repository. Changes to installation or starting cowrie would need to be done on both. Merging this into one repository prevents that those will be forgotten and makes it easier to understand why changes happen. The dockerfile is a different one then the one from the docker-cowrie repository. I chose to use a python2-alpine linux. In the end this image has 55% smaller image size than the Debian image. The build process is split into to parts. The first image has everything installed to compile the python modules. The second one has only things installed which are needed to run the daemon. There is no need to install python-virtualenv because we are using docker. We don't need that much layers. Twisted can drop his privileges when starting the daemon when `--uid` and `--gid` is passed. This works only with numerical id. The user nobody is used for this. This is on Docker a good idea since there should be only one service with this user running. In other systems there might be several services using this daemon which is not a good choise. When building a new Docker image for cowrie Docker multistage build images are created running flake8 and unittests to ensure that all future releases are stable and matching our code guidelines. Bonus effect is when using this as a git pre-push-hook a developer doesn't need to wait for travis to fail on an error. Based on the current project structure we need a lot of `COPY` instructions inside the dockerfile which has negative sideeffects. - bloading the dockerfile up - longer buildtimes - more layers are created - more diskspace is used We should find a way to reduce this. Best way for doing this is keeping the static files like `honeyfs` and `share` right next to the source code. * Removing UID 0 check Cowrie checked on startup if it was started with root privileges. This conflicts with the option to let cowrie drop his privileges on startup using the twisted option `--uid` and `--gid`. I tested it a day ago without removing the code block and it run through but now it is for some reasons blocking. My feeling is that the code for droping privileges is also asynchron and sometimes the check is faster then the dropping of the privileges. But I might be wrong here. The solution is to remove the hole check. Considering that the check is there for preventing new users to shoot their feet we fixed this problem on different levels. New users should the docker images which are far easier to control and deploy then everything else because we take care. If a user wants to deploy it from scratch onto their serves there is a install instruction with detailed steps. This steps includes creating a special system user for cowrie and starting it with this user. * Fix missing directory, simplify path I missed to create the TTY log path. That's now fixed. Also the path for the trial command has been simplified. * Revert "Removing UID 0 check" This reverts commit f76329cd798744d10a0f52281e5a3588955d2531. * Introducint ENV var COWRIE_DOCKER The variable is used inside the docker image to let cowrie know that it is running inside docker and don't need to perform the "running as root" check. Inside the docker image cowrie is started with the `--uid` and `--gid` option and will drop to a different user then root. * Restructured Dockerfile, Added cowrie user The image is now builded with a user and group for running in the later image cowrie. Also the build steps are re-aranged to save build time. We assume that static files like `honeyfs` and `share` are less frequently updated and can be build into the base image where every other images is based on. * Renamed directory src -> cowrie The name cowrie should be more self-explaining then src. * Update cowrie_plugin.py
2018-08-06 08:27:32 +00:00
COPY --from=builder /root/wheelhouse /root/wheelhouse
RUN pip3 install -r requirements.txt --no-index --find-links=/root/wheelhouse
RUN pip3 install -r requirements-output.txt --no-index --find-links=/root/wheelhouse
FROM post-builder as pre-devel
RUN pip3 install flake8 flake8-import-order pytest
Full docker support (#830) * Full docker support Currently Docker images are build by a second git repository. Changes to installation or starting cowrie would need to be done on both. Merging this into one repository prevents that those will be forgotten and makes it easier to understand why changes happen. The dockerfile is a different one then the one from the docker-cowrie repository. I chose to use a python2-alpine linux. In the end this image has 55% smaller image size than the Debian image. The build process is split into to parts. The first image has everything installed to compile the python modules. The second one has only things installed which are needed to run the daemon. There is no need to install python-virtualenv because we are using docker. We don't need that much layers. Twisted can drop his privileges when starting the daemon when `--uid` and `--gid` is passed. This works only with numerical id. The user nobody is used for this. This is on Docker a good idea since there should be only one service with this user running. In other systems there might be several services using this daemon which is not a good choise. When building a new Docker image for cowrie Docker multistage build images are created running flake8 and unittests to ensure that all future releases are stable and matching our code guidelines. Bonus effect is when using this as a git pre-push-hook a developer doesn't need to wait for travis to fail on an error. Based on the current project structure we need a lot of `COPY` instructions inside the dockerfile which has negative sideeffects. - bloading the dockerfile up - longer buildtimes - more layers are created - more diskspace is used We should find a way to reduce this. Best way for doing this is keeping the static files like `honeyfs` and `share` right next to the source code. * Removing UID 0 check Cowrie checked on startup if it was started with root privileges. This conflicts with the option to let cowrie drop his privileges on startup using the twisted option `--uid` and `--gid`. I tested it a day ago without removing the code block and it run through but now it is for some reasons blocking. My feeling is that the code for droping privileges is also asynchron and sometimes the check is faster then the dropping of the privileges. But I might be wrong here. The solution is to remove the hole check. Considering that the check is there for preventing new users to shoot their feet we fixed this problem on different levels. New users should the docker images which are far easier to control and deploy then everything else because we take care. If a user wants to deploy it from scratch onto their serves there is a install instruction with detailed steps. This steps includes creating a special system user for cowrie and starting it with this user. * Fix missing directory, simplify path I missed to create the TTY log path. That's now fixed. Also the path for the trial command has been simplified. * Revert "Removing UID 0 check" This reverts commit f76329cd798744d10a0f52281e5a3588955d2531. * Introducint ENV var COWRIE_DOCKER The variable is used inside the docker image to let cowrie know that it is running inside docker and don't need to perform the "running as root" check. Inside the docker image cowrie is started with the `--uid` and `--gid` option and will drop to a different user then root. * Restructured Dockerfile, Added cowrie user The image is now builded with a user and group for running in the later image cowrie. Also the build steps are re-aranged to save build time. We assume that static files like `honeyfs` and `share` are less frequently updated and can be build into the base image where every other images is based on. * Renamed directory src -> cowrie The name cowrie should be more self-explaining then src. * Update cowrie_plugin.py
2018-08-06 08:27:32 +00:00
FROM pre-devel as devel
USER cowrie
Full docker support (#830) * Full docker support Currently Docker images are build by a second git repository. Changes to installation or starting cowrie would need to be done on both. Merging this into one repository prevents that those will be forgotten and makes it easier to understand why changes happen. The dockerfile is a different one then the one from the docker-cowrie repository. I chose to use a python2-alpine linux. In the end this image has 55% smaller image size than the Debian image. The build process is split into to parts. The first image has everything installed to compile the python modules. The second one has only things installed which are needed to run the daemon. There is no need to install python-virtualenv because we are using docker. We don't need that much layers. Twisted can drop his privileges when starting the daemon when `--uid` and `--gid` is passed. This works only with numerical id. The user nobody is used for this. This is on Docker a good idea since there should be only one service with this user running. In other systems there might be several services using this daemon which is not a good choise. When building a new Docker image for cowrie Docker multistage build images are created running flake8 and unittests to ensure that all future releases are stable and matching our code guidelines. Bonus effect is when using this as a git pre-push-hook a developer doesn't need to wait for travis to fail on an error. Based on the current project structure we need a lot of `COPY` instructions inside the dockerfile which has negative sideeffects. - bloading the dockerfile up - longer buildtimes - more layers are created - more diskspace is used We should find a way to reduce this. Best way for doing this is keeping the static files like `honeyfs` and `share` right next to the source code. * Removing UID 0 check Cowrie checked on startup if it was started with root privileges. This conflicts with the option to let cowrie drop his privileges on startup using the twisted option `--uid` and `--gid`. I tested it a day ago without removing the code block and it run through but now it is for some reasons blocking. My feeling is that the code for droping privileges is also asynchron and sometimes the check is faster then the dropping of the privileges. But I might be wrong here. The solution is to remove the hole check. Considering that the check is there for preventing new users to shoot their feet we fixed this problem on different levels. New users should the docker images which are far easier to control and deploy then everything else because we take care. If a user wants to deploy it from scratch onto their serves there is a install instruction with detailed steps. This steps includes creating a special system user for cowrie and starting it with this user. * Fix missing directory, simplify path I missed to create the TTY log path. That's now fixed. Also the path for the trial command has been simplified. * Revert "Removing UID 0 check" This reverts commit f76329cd798744d10a0f52281e5a3588955d2531. * Introducint ENV var COWRIE_DOCKER The variable is used inside the docker image to let cowrie know that it is running inside docker and don't need to perform the "running as root" check. Inside the docker image cowrie is started with the `--uid` and `--gid` option and will drop to a different user then root. * Restructured Dockerfile, Added cowrie user The image is now builded with a user and group for running in the later image cowrie. Also the build steps are re-aranged to save build time. We assume that static files like `honeyfs` and `share` are less frequently updated and can be build into the base image where every other images is based on. * Renamed directory src -> cowrie The name cowrie should be more self-explaining then src. * Update cowrie_plugin.py
2018-08-06 08:27:32 +00:00
FROM pre-devel as tests
COPY src /cowrie
Full docker support (#830) * Full docker support Currently Docker images are build by a second git repository. Changes to installation or starting cowrie would need to be done on both. Merging this into one repository prevents that those will be forgotten and makes it easier to understand why changes happen. The dockerfile is a different one then the one from the docker-cowrie repository. I chose to use a python2-alpine linux. In the end this image has 55% smaller image size than the Debian image. The build process is split into to parts. The first image has everything installed to compile the python modules. The second one has only things installed which are needed to run the daemon. There is no need to install python-virtualenv because we are using docker. We don't need that much layers. Twisted can drop his privileges when starting the daemon when `--uid` and `--gid` is passed. This works only with numerical id. The user nobody is used for this. This is on Docker a good idea since there should be only one service with this user running. In other systems there might be several services using this daemon which is not a good choise. When building a new Docker image for cowrie Docker multistage build images are created running flake8 and unittests to ensure that all future releases are stable and matching our code guidelines. Bonus effect is when using this as a git pre-push-hook a developer doesn't need to wait for travis to fail on an error. Based on the current project structure we need a lot of `COPY` instructions inside the dockerfile which has negative sideeffects. - bloading the dockerfile up - longer buildtimes - more layers are created - more diskspace is used We should find a way to reduce this. Best way for doing this is keeping the static files like `honeyfs` and `share` right next to the source code. * Removing UID 0 check Cowrie checked on startup if it was started with root privileges. This conflicts with the option to let cowrie drop his privileges on startup using the twisted option `--uid` and `--gid`. I tested it a day ago without removing the code block and it run through but now it is for some reasons blocking. My feeling is that the code for droping privileges is also asynchron and sometimes the check is faster then the dropping of the privileges. But I might be wrong here. The solution is to remove the hole check. Considering that the check is there for preventing new users to shoot their feet we fixed this problem on different levels. New users should the docker images which are far easier to control and deploy then everything else because we take care. If a user wants to deploy it from scratch onto their serves there is a install instruction with detailed steps. This steps includes creating a special system user for cowrie and starting it with this user. * Fix missing directory, simplify path I missed to create the TTY log path. That's now fixed. Also the path for the trial command has been simplified. * Revert "Removing UID 0 check" This reverts commit f76329cd798744d10a0f52281e5a3588955d2531. * Introducint ENV var COWRIE_DOCKER The variable is used inside the docker image to let cowrie know that it is running inside docker and don't need to perform the "running as root" check. Inside the docker image cowrie is started with the `--uid` and `--gid` option and will drop to a different user then root. * Restructured Dockerfile, Added cowrie user The image is now builded with a user and group for running in the later image cowrie. Also the build steps are re-aranged to save build time. We assume that static files like `honeyfs` and `share` are less frequently updated and can be build into the base image where every other images is based on. * Renamed directory src -> cowrie The name cowrie should be more self-explaining then src. * Update cowrie_plugin.py
2018-08-06 08:27:32 +00:00
ENV PYTHONPATH=/cowrie
WORKDIR /cowrie
RUN flake8 --count --application-import-names cowrie --max-line-length=120 --statistics . && \
trial cowrie
FROM post-builder as pre-release
RUN apt-get remove -y python3-pip && \
apt-get autoremove -y && \
apt-get autoclean -y && \
rm -rf /root/wheelhouse && \
rm -rf /var/lib/apt/lists/* && \
rm -rf /var/log/*
COPY src /cowrie
RUN find /cowrie -type d -exec chmod 755 {} \; && \
find /cowrie -type f -exec chmod 744 {} \;
Full docker support (#830) * Full docker support Currently Docker images are build by a second git repository. Changes to installation or starting cowrie would need to be done on both. Merging this into one repository prevents that those will be forgotten and makes it easier to understand why changes happen. The dockerfile is a different one then the one from the docker-cowrie repository. I chose to use a python2-alpine linux. In the end this image has 55% smaller image size than the Debian image. The build process is split into to parts. The first image has everything installed to compile the python modules. The second one has only things installed which are needed to run the daemon. There is no need to install python-virtualenv because we are using docker. We don't need that much layers. Twisted can drop his privileges when starting the daemon when `--uid` and `--gid` is passed. This works only with numerical id. The user nobody is used for this. This is on Docker a good idea since there should be only one service with this user running. In other systems there might be several services using this daemon which is not a good choise. When building a new Docker image for cowrie Docker multistage build images are created running flake8 and unittests to ensure that all future releases are stable and matching our code guidelines. Bonus effect is when using this as a git pre-push-hook a developer doesn't need to wait for travis to fail on an error. Based on the current project structure we need a lot of `COPY` instructions inside the dockerfile which has negative sideeffects. - bloading the dockerfile up - longer buildtimes - more layers are created - more diskspace is used We should find a way to reduce this. Best way for doing this is keeping the static files like `honeyfs` and `share` right next to the source code. * Removing UID 0 check Cowrie checked on startup if it was started with root privileges. This conflicts with the option to let cowrie drop his privileges on startup using the twisted option `--uid` and `--gid`. I tested it a day ago without removing the code block and it run through but now it is for some reasons blocking. My feeling is that the code for droping privileges is also asynchron and sometimes the check is faster then the dropping of the privileges. But I might be wrong here. The solution is to remove the hole check. Considering that the check is there for preventing new users to shoot their feet we fixed this problem on different levels. New users should the docker images which are far easier to control and deploy then everything else because we take care. If a user wants to deploy it from scratch onto their serves there is a install instruction with detailed steps. This steps includes creating a special system user for cowrie and starting it with this user. * Fix missing directory, simplify path I missed to create the TTY log path. That's now fixed. Also the path for the trial command has been simplified. * Revert "Removing UID 0 check" This reverts commit f76329cd798744d10a0f52281e5a3588955d2531. * Introducint ENV var COWRIE_DOCKER The variable is used inside the docker image to let cowrie know that it is running inside docker and don't need to perform the "running as root" check. Inside the docker image cowrie is started with the `--uid` and `--gid` option and will drop to a different user then root. * Restructured Dockerfile, Added cowrie user The image is now builded with a user and group for running in the later image cowrie. Also the build steps are re-aranged to save build time. We assume that static files like `honeyfs` and `share` are less frequently updated and can be build into the base image where every other images is based on. * Renamed directory src -> cowrie The name cowrie should be more self-explaining then src. * Update cowrie_plugin.py
2018-08-06 08:27:32 +00:00
FROM pre-release as release
LABEL maintainer="Florian Pelgrim <florian.pelgrim@craneworks.de>"
Full docker support (#830) * Full docker support Currently Docker images are build by a second git repository. Changes to installation or starting cowrie would need to be done on both. Merging this into one repository prevents that those will be forgotten and makes it easier to understand why changes happen. The dockerfile is a different one then the one from the docker-cowrie repository. I chose to use a python2-alpine linux. In the end this image has 55% smaller image size than the Debian image. The build process is split into to parts. The first image has everything installed to compile the python modules. The second one has only things installed which are needed to run the daemon. There is no need to install python-virtualenv because we are using docker. We don't need that much layers. Twisted can drop his privileges when starting the daemon when `--uid` and `--gid` is passed. This works only with numerical id. The user nobody is used for this. This is on Docker a good idea since there should be only one service with this user running. In other systems there might be several services using this daemon which is not a good choise. When building a new Docker image for cowrie Docker multistage build images are created running flake8 and unittests to ensure that all future releases are stable and matching our code guidelines. Bonus effect is when using this as a git pre-push-hook a developer doesn't need to wait for travis to fail on an error. Based on the current project structure we need a lot of `COPY` instructions inside the dockerfile which has negative sideeffects. - bloading the dockerfile up - longer buildtimes - more layers are created - more diskspace is used We should find a way to reduce this. Best way for doing this is keeping the static files like `honeyfs` and `share` right next to the source code. * Removing UID 0 check Cowrie checked on startup if it was started with root privileges. This conflicts with the option to let cowrie drop his privileges on startup using the twisted option `--uid` and `--gid`. I tested it a day ago without removing the code block and it run through but now it is for some reasons blocking. My feeling is that the code for droping privileges is also asynchron and sometimes the check is faster then the dropping of the privileges. But I might be wrong here. The solution is to remove the hole check. Considering that the check is there for preventing new users to shoot their feet we fixed this problem on different levels. New users should the docker images which are far easier to control and deploy then everything else because we take care. If a user wants to deploy it from scratch onto their serves there is a install instruction with detailed steps. This steps includes creating a special system user for cowrie and starting it with this user. * Fix missing directory, simplify path I missed to create the TTY log path. That's now fixed. Also the path for the trial command has been simplified. * Revert "Removing UID 0 check" This reverts commit f76329cd798744d10a0f52281e5a3588955d2531. * Introducint ENV var COWRIE_DOCKER The variable is used inside the docker image to let cowrie know that it is running inside docker and don't need to perform the "running as root" check. Inside the docker image cowrie is started with the `--uid` and `--gid` option and will drop to a different user then root. * Restructured Dockerfile, Added cowrie user The image is now builded with a user and group for running in the later image cowrie. Also the build steps are re-aranged to save build time. We assume that static files like `honeyfs` and `share` are less frequently updated and can be build into the base image where every other images is based on. * Renamed directory src -> cowrie The name cowrie should be more self-explaining then src. * Update cowrie_plugin.py
2018-08-06 08:27:32 +00:00
ENV PYTHONPATH=/cowrie
WORKDIR /cowrie
EXPOSE 2222/tcp
EXPOSE 2223/tcp
USER cowrie
CMD /usr/bin/python3 /usr/local/bin/twistd --umask 0022 --nodaemon --pidfile= -l - cowrie