Skip to content

Instantly share code, notes, and snippets.

@evgenii-malov
Last active October 14, 2016 23:04
Show Gist options
  • Save evgenii-malov/f144db27dfab8854b848d2a5a303a692 to your computer and use it in GitHub Desktop.
Save evgenii-malov/f144db27dfab8854b848d2a5a303a692 to your computer and use it in GitHub Desktop.
docker workflow

Docker workflow

example Dockerfile

Dockerfile
FROM davidjfelix/python3.5
RUN pip3 install aiohttp
RUN pip3 install aiomysql
ADD . /seo_server
WORKDIR /seo_server
CMD python seo_server.py

sudo docker build -t <image> .

sudo docker run -i -t —entrypoint /bin/bash <imageID>

sudo docker run -d -p 80:5000 <image> .

sudo docker ps

sudo docker run -p 127.0.0.1:8888:8888 -i -t seo_server

sudo dockerun -p 127.0.0.1:8888:8888 -i -t —net=host echo_server_1 # works forwarding!

sudo docker exec -i -t 665b4a1e17b6 /bin/bash #by ID #coonect to container

sudo docker rmi -f <image> #delete image

sudo docker search "image name to search"

--net=host — Tells Docker to skip placing the container inside of a separate network stack. In essence, this choice tells Docker to not containerize the container's networking! While container processes will still be confined to their own filesystem and process list and resource limits, a quick ip addr command will show you that, network-wise, they live “outside” in the main Docker host and have full access to its network interfaces. Note that this does not let the container reconfigure the host network stack — that would require —privileged=true — but it does let container processes open low-numbered ports like any other root process. It also allows the container to access local network services like D-bus. This can lead to processes in the container being able to do unexpected things like restart your computer. You should use this option with caution.

transfer docker image:

docker save -o <save image to path> <image name> #transfer docker image from local to server:

docker load -i <path to image tar file> #load the image into docker:

sudo docker run -v /media/se7en/bighdd/projects/linktolink/servers/python3.5:/sources -p 127.0.0.1:8888:8888 -i -t --net=host --entrypoint /usr/local/bin/python l2l_python3.5 /sources/seo_server/seo_server.py --silent=True

sudo docker run -v /home/se7en/workspace/linktolink/servers/python3.5:/sources -p 127.0.0.1:8888:8888 -i -t --net=host --entrypoint /usr/local/bin/python l2l_python3.5 /sources/seo_server/seo_server.py

sudo docker run --name=seo_server --restart=always -v /home/se7en/workspace/linktolink/servers/python3.5:/sources -p 127.0.0.1:8888:8888 -i -t --net=host --entrypoint /usr/local/bin/python l2l_python3.5 /sources/seo_server/seo_server.py

sudo docker run --name=seo_client --restart=always -v /home/se7en/workspace/linktolink/servers/python3.5:/sources -p 127.0.0.1:8888:8888 -i -t --net=host --entrypoint /usr/local/bin/python l2l_python3.5 /sources/seo_server/client.py

sudo docker restart container_id1 container_id2 container_id3

sudo docker run -v /home/se7en/workspace/linktolink/servers/python3.5:/sources -i -t --net=host --entrypoint /usr/local/bin/python l2l_python3.5 /sources/seo_server/test.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment