With centos in a docker container, I just type 'docker attach container ID' and it takes me to the shell prompt, where i can install and configure nginx.
This one is easier: docker.com dockerfile/nginx You just run the file and everything is installed and configured.
but i can't figure out how to get in and access the files.
If you want to see the dockerfile, then you can go to docker hub and type the image name and version name in the tag format (e.g ubuntu:14.04) this will open the image along with Docker file details. Also keep in mind, only if the owner of the image shared their Dockerfile, you can see it.
In my case the standard bash didn't exist. Using /bin/sh helped me:
docker run -it -p 80:80 dockerfile/nginx /bin/sh
UPDATE (a much easier method that was introduced later):
docker exec -t -i container_name /bin/bash
Original answer
Actually you can access a running container too.
Find your container's ID:
docker ps
Export the ID of the process that runs the container:
PID=$(docker inspect --format '{{.State.Pid}}' my_container_id)
"Connect" to it by changing namespaces:
nsenter --target $PID --mount --uts --ipc --net --pid
Originally this was described here: http://jpetazzo.github.io/2014/03/23/lxc-attach-nsinit-nsenter-docker-0-9/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With