问题
My main objective is to get an image up and running quickly and easily while persisting data. I THINK an ACI is the best way to do this. Assuming this is true...
[Edit2] It appears that there may be a more fundamental problem is the inability to specify a hostname like you can in docker. I will ask that question in a separate thread. I was able to attach storage.
[Original post] I would like to use an ACI to setup this an image that is on Docker Hub. I have been able to follow the simple tutorial here but I need to attach storage.
Specifically, this is the image that I am using: https://hub.docker.com/r/sverhoeven/cartodb/
These are are instructions for how to setup persistent data but I don't think they will translate directly to an ACI. This is taken from the "Persistent Data" section of that docker hub page
To persist the PostgreSQL data, the PostGreSQL data dir (/var/lib/postgresql) must be persisted outside the Cartodb Docker container.…
Make a temporary container
docker create --name cartodb_pgdata sverhoeven/cartodb
Save the Postgresql data dir (cartodb_pgdata) to local directory. ** how do we do this with ACI?
docker cp cartodb_pgdata:/var/lib/postgresql $PWD/cartodb_pgdata docker rm -f cartodb_pgdata
Setup ownership of cartodb_pgdata to the (uid=105) user on file system. ** How do we do this with ACI?
sudo chown -R 105.105 $PWD/cartodb_pgdata
After this the CartoDB container will have a database that stays filled after restarts. The CartoDB container can be started with
docker run -d -p 80:80 -h cartodb.example.com -v $PWD/cartodb_pgdata:/var/lib/PostgreSQL sverhoeven/cartodb
There are a number of questions for which I am having trouble finding solutions, eg:
- I don't know whether to use emptyDir or an Azure file share.
- I don't know how to edit ownership
- I don't know how to setup the ACI to invoke specific docker run commands when spinning up a container
回答1:
You should use Azure file share as emptyDir is not a persistent storage. Essentially what you need is add a file share volume in your container group and mount it at /var/lib/PostgreSQL. The file share volume will be mounted with 777 permission by default.
Since you already passed the volume info when you create container, e.g. az container create
via CLI, that translate to underlying docker run
equivalent. there is no need to specify docker command.
How to mount a file share: https://docs.microsoft.com/en-us/azure/container-instances/container-instances-volume-azure-files
来源:https://stackoverflow.com/questions/50915321/setting-up-persistent-data-for-carto-postgresql-on-aci