Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I enter this dockerfile / nginx container?

Tags:

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.

like image 983
peruvian Avatar asked Sep 24 '14 09:09

peruvian


People also ask

Where is Dockerfile in container?

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.


2 Answers

In my case the standard bash didn't exist. Using /bin/sh helped me:

docker run -it -p 80:80 dockerfile/nginx /bin/sh 
like image 97
SJX Avatar answered Oct 24 '22 00:10

SJX


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/

like image 32
Tadas Šubonis Avatar answered Oct 24 '22 00:10

Tadas Šubonis