title: docker service with compose file single node and local image
body: <p>So I need rolling-updates with <code>docker</code> on my <strong>single node server</strong>. Until now, I was using <code>docker-compose</code> but unfortunately, I can't achieve what I need with it. Reading the web, <code>docker-swarm</code> seems to be the way to go.</p>
  
  <p>I have found how to run an app with multiple replicas on a single node using swarm:</p>
  
  <pre><code>docker service create --replicas 3 --name myapp-staging myapp_app:latest
  </code></pre>
  
  <p><code>myapp:latest</code> being built from my <code>docker-compose.yml</code>:</p>
  
  <pre><code>version: "3.6"
  
  services:
    postgres:
      env_file:
        - ".env"
      image: "postgres:11.0-alpine"
      volumes:
        - "/var/run/postgresql:/var/run/postgresql"
    app:
      build: "."
      working_dir: /app
      depends_on:
        - "postgres"
      env_file:
        - ".env"
      command: iex -S mix phx.server
      volumes:
        - ".:/app"
  
  volumes:
    postgres: {}
    static:
      driver_opts:
        device: "tmpfs"
        type: "tmpfs"
  
  </code></pre>
  
  <p>Unfortunately, this doesn't work since it doesn't get the config from the <code>docker-compose.yml</code> file: <code>.env</code> file, <code>command</code> entry etc.</p>
  
  <p>Searching deeper, I find that using </p>
  
  <pre><code>docker stack deploy -c docker-compose.yml &lt;name&gt;
  </code></pre>
  
  <p>will create a service using my <code>docker-compose.yml</code> config.</p>
  
  <p>But then I get the following error message:</p>
  
  <blockquote>
    <p>failed to update service myapp-staging_postgres: Error response from daemon: rpc error: code = InvalidArgument desc = ContainerSpec: image reference must be provided</p>
  </blockquote>
  
  <p>So it seems I have to use the registry and push my image there so that it works. I understand this need in case of a multiple node architecture, but in my case <strong>I don't want to do that</strong>. (Carrying images are heavy, I don't want my image to be public, and after all, image is <strong>here</strong>, so why should I move it to the internet?)</p>
  
  <p>How can I set up my <code>docker service</code> using local image and config written in <code>docker-compose.yml</code>? </p>
  
  <p>I could probably manage my way using <code>docker service create</code> options, but that wouldn't use my <code>docker-compose.yml</code> file so it would not be DRY nor maintainable, which is important to me.</p>
  
  <p><code>docker-compose</code> is a great tool for developers, it is sad that we have to dive into DevOps tools to achieve such common features as rolling updates. This whole swarm architecture seems too complicated for my needs at this stage.</p>