HOW TO - Access Files in a Docker Container

Any issue about installation and configuration of the Cyclos 4 version

Moderators: hugo, alexandre, rmvanarkel

Post Reply
dman
Posts: 26
Joined: Tue May 30, 2017 10:13 am

HOW TO - Access Files in a Docker Container

Post by dman » Sun Jun 18, 2017 3:30 pm

I was stuck and frustrated at trying to access the server.xml file in my Docker installation. Docker is a virtual environment and as such, it has its own file system inside of the Docker container. Accessing that file system is possible, but it is by definition, not directly accessible from the host machine. My environment consists of the fllowing:

Ubuntu 16.04 LTS (Xenial)
Docker (latest version)
Cyclos 4.8 Docker image

Docker provides a mechanism, through the Docker CLI, for admins to access a Docker terminal shell within a container where the user can utilize the vi text editor to make the edits to the server.xml file which is located in the /usr/local/tomcat/conf folder. In order to access the container the user will need the docker container id. This can be obtained by entering

Code: Select all

$ sudo docker ps

at the command prompt (assuming you are not operating as root which is highly recommended).This will give the user some output on the running Docker containers including the container id. Once you obtain the container id, the next step is to enter the container and get a command prompt.

Code: Select all

$ sudo docker exec -it <container id> sh

I got an error using bash but I was successful just getting a shell (sh).

Once you are at the Docker command prompt (#) you can cd to the /usr/local/tomcat/conf directory and issue a list contents command

Code: Select all

# ls -a
Which will return a listing of the contents of the directory. To open the server.xml file simply issue an open command with the vi editor

Code: Select all

# vi server.xml
This will open the file in the vi editor. Find the Connector directive and uncomment it by removing the !-- at the beginning of the statement. To edit, move the cursor to the edit point and press "i". Then you can move the cursor and delete or add text.
Here is a helpful link https://www.cs.colostate.edu/helpdocs/vi.html for vi commands.

Post Reply