0

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
rubenk
  • 41
  • 7
  • I haven't gotten any suggestions for a little bit. At the risk of looking like I am asking the same thing twice, I will upload a more precise question about the issue with hostname specification. Generally speaking, the answer from @anders did help me get started with attaching a file share. – rubenk Jun 21 '18 at 01:54
  • 1
    I asked my hostname question here: https://stackoverflow.com/questions/50959411/is-there-a-way-to-specify-hostname-when-starting-container-on-azure-cloud-instan – rubenk Jun 21 '18 at 02:17

1 Answers1

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://learn.microsoft.com/en-us/azure/container-instances/container-instances-volume-azure-files

Anders
  • 331
  • 2
  • 4
  • I see. I will have to look into the CLI. I didn't touch that yet. I just used the standard step-by-step workflow to setup the instance. I'll look into this in the next couple of days and will post back here. – rubenk Jun 19 '18 at 02:29
  • I can't start the container with the fileshare mounted. I am getting errors on startup. `* Starting PostgreSQL 9.5 database server` * Error: /var/lib/postgresql/9.5/main is not accessible or does not exist ...fail! …. cartodb/config/environments/development.js" Windshaft tileserver 6.1.1 started on 0.0.0.0:8181 PID=86 (development) rake aborted! PG::Error: could not connect to server: Connection refused Is the server running on host "localhost" (::1) and accepting TCP/IP connections on port 5432? ` etc etc etc – rubenk Jun 20 '18 at 00:42
  • I think that this section `/var/lib/postgresql/9.5/main` is because of me mounting the filesystem – rubenk Jun 20 '18 at 00:50
  • Sure enough, when I start the container without mounting the file share to that directory, it boots: `* Starting PostgreSQL 9.5 database server ...done. Starting redis-server: redis-server. * Starting nginx nginx ...done. --- Restoring user metadata etc – rubenk Jun 20 '18 at 01:47
  • The site is not fully loading. I think there is still a problem with not specifying the hostname. ```Started GET "/" for 127.0.0.1 at 2018-06-20 01:53:59 +0000 Processing by Admin::PagesController#index as */* ... Redirected to http://localhost/login ... Started GET "/favicon.ico" for 127.0.0.1 at 2018-06-20 01:54:25 +0000 ActionController::RoutingError (No route matches [GET] "/favicon.ico"): Started POST "/sessions/create" for 127.0.0.1 at 2018-06-20 01:54:39 +0000 Started GET "/user/dev/dashboard/" for 127.0.0.1 at 2018-06-20 01:54:39 +0000 ``` – rubenk Jun 20 '18 at 02:12
  • Just noting that my issues had to do with permissions issues. I will mark the best answer but warn folks that there is currently a problem for me with file ownership. This may be the case for others too – rubenk Jul 26 '18 at 04:47