Can I specify a custom location for docker temporary files? - docker

I'm trying to run docker in a partially locked-down environment, with /etc on a read-only mount point and a "/data" folder in a read/write mount point. I've added an /etc/docker/daemon.json file:
{
"data-root": "/data/docker"
}
but dockerd is failing on startup with this error:
failed to start daemon: Error saving key file: open /etc/docker/.tmp-key.json128868007: read-only file system
Can I stop dockerd from trying to write into /etc? Are there best practices for running docker on a host with read-only mounts?
EDIT: Turns out there was only one file being written: /etc/docker/key.json which is talked about in detail here. The .tmp-key.json bit is likely a part of some atomic file write code.

Looks like only the "key.json" file is written to /etc. After some digging, I found this PR which talks about making it configurable. As of docker 19.03.6, the option is still available for use in the daemon.json file as "deprecated-key-path": "/path/to/file".

Related

Error writing daemon.json: Read-only file system on docker

I want to configure docker installed with snap
on the way
/snap/docker/current/config daemon.json file
I edit I see this message when saving the file
[ File 'daemon.json' is unwritable ]
By the way, I am working as **root **user
Does anyone know which access I should change?
I tried with the command
snap stop docker
to top the Docker service. But there was no change in the permission to write to the file

Can't mount docker volume to run opentelemetry image

I try to run a opentelemetry docker image with the config yaml file as an argument :
docker run -v "./otel-collector-config.yaml":/otel-collector-config.yaml -p 4317:4317 otel/opentelemetry-collector:latest --config=otel-collector-config.yaml
I keep getting this error message :
2021-10-01T08:21:05.384Z info service/collector.go:303 Starting otelcol... {"Version": "0.35.0", "NumCPU": 12}
2021-10-01T08:21:05.384Z info service/collector.go:242 Loading configuration...
Error: cannot load configuration's parser: error loading config file "/etc/otel-collector-config.yaml": unable to read the file /etc/otel-collector-config.yaml: read /etc/otel-collector-config.yaml: is a directory
2021/10/01 08:21:05 application run finished with error: cannot load configuration's parser: error loading config file "/etc/otel-collector-config.yaml": unable to read the file /etc/otel-collector-config.yaml: read /etc/otel-collector-config.yaml: is a directory
Seems like the app cannot read the file passed in volume, as it appears to be a directory, rather than a file.
Does anyone have a clue how I could get this file to be mounted as a file, or guide me toward what I am doing wrong ?
I have tried all possible combination of with/without " around the files name or also playing with = to var assignement - nothing worked so far.
Please note that I am working on Windows, in case this would a operating system's related issue.
I finally found an answer, thanks to this post
You need to specify the full path of the file you want to mount.
If not, because docker will not find the fill, it will create an empty directory based on the name of the file !

Docker-compose throwing error

Hello guys I'm trying to get my vagrant up but the docker keeps on throwing an error which is given below :
Can't find a suitable configuration file in this directory or any parent. Are you in the right directory
The file is present at the root of my project. It was all working well but it just started to throw an error. Can somebody tell me what is it that I have done due to which I'm getting this error
well, I had this error but it was due to vagrant. If you are running vagrant then first of all enter into your vagrant machine using :
vagrant ssh command
and try to find the file over there. If you don't have it over there then this is the problem. That file is not being loaded over here because of which you are getting this error.
My error was coming because vagrant was not mounting the nfs partition because of which the whole project was not loading in the vagrant machine and after that, the docker command was being run. Since the project was not being loaded docker command was not able to find the required file.
If this is your problem try to mount your nfs partition first.
Run:
docker-compose -f rootoftheprojectpath/docker-compose.yml up -d
Check read permissions, typos, etc. Also check that your file is not empty
Regards

docker-compose caches run results

I'm having an issue with docker-compose where I'm passing a file into the container when it's run. The issue is that it doesn't seem to recognize when the file has been changed and serves the saved result back indefinitely until I change the name of the file.
An example (modified names for brevity):
jono#macbook:~/myProj% docker-compose run vpn conf.opvn
Options error: Unrecognized option or missing parameter(s) in conf.opvn:71: AXswRE+
5aN64mYiPSatOACC6+bISv8RcDPX/lMYdLwe8zQY6qWtbrjFXrp2 (2.3.8)
Then I change the file, save it, and run the command again - exact same output.
Then without changing anything I do this:
jono#macbook:~/myProj% cp conf.opvn newconf.opvn
And when I run $ docker-compose run vpn newconf.opvn it works. Seems really silly.
I'm working with Tmux and Mac if there is some way that affects it. Is this the expected behaviour? I couldn't find anything documenting this on the docker-compose homepage.
EDIT:
Specifically I'm using this repo from the amazing Jess.
The image you are using is using volume in order to mount your current directory. Basically the file conf.opvn is copied to the docker container.
When you change the file, the container doesn't see that change, but it does pick up the rename (which the container sees as a new file). This most probably is due to user rights of the file and the user rights of the folder in the docker container where this file is mounted. Try changing the file's permissions to 777 before beginning the process and check again.
You can find a discussion about this in the official forum of docker

How to set volume for dokku-persistent-storage

I am trying to use dokku-persistent-storage so my uploads for my rails app stay on the server, but I don't quite understand how to build the path since I am new to Dokku and Docker.
(I am running this on an Ubuntu droplet on Digital Ocean)
I'm not sure if it should be something like this:
[SERVER IP ADDRESS]/home/dokku/myapp/public_folder
or
/home/dokku/myapp/public_folder
or if i'm way off and it should be something completely different.
This is what the github section says about it:
In your applications folder (/home/dokku/app_name) create a file called PERSISTENT_STORAGE.
Inside this file list one volume-map/volume per line to mount. For example:
/host/path:/container/path
/another/container/path
The above example will result in the following arguments being passed to docker during deploy and docker run:
-v /host/path:/container/path -v /another/container/path
Move information on docker volumes can be found here: http://docs.docker.io/en/latest/use/working_with_volumes/
I am not into Ruby or dokku, but if I understood correctly, you want your docker to have a persistent storage on the host machine.
PERSISTENT_STORAGE file, as to the documentation that you've quoted, contains mappings from host file-system directories to your container file-system directories (translated to -v arguments of the CLI).
Therefore, you should map the directory of your uploads in the container, to the desired directory on the host.
For example, if your app's uploads are saved to this dir (inside the docker container):
/home/dokku/myapp/public_folder
and you'd like them to be kept in your host at:
/home/some/dir
then, as I understand, the content of PERSISTENT_STORAGE file should be:
/home/some/dir:/home/dokku/myapp/public_folder
I hope I got you right.
Use Dokku's storage:mount option.
You'll need to SSH into your dokku host:
ssh dokku#host
Run the following command to link the storage directory for that app to the app/public/uploads folder, for example:
storage:mount <app> /var/lib/dokku/data/storage:/app/public/uploads
The Dokku docs cover this well at: at http://dokku.viewdocs.io/dokku/advanced-usage/persistent-storage/

Resources