6

This is steps I have done

prisma init

I set postgresql for database in my local(not exist).

It created 3 files, datamodel.graphql, docker-compose.yml, prisma.yml

docker-compose up -d

I confirmed it running successfully enter image description here But if I call prisma deploy, it shows me error

Could not connect to server at http://localhost:4466. Please check if your server is running.

All I have done is standard operation described in manual and there is no customization in https://www.prisma.io/docs/tutorials/deploy-prisma-servers/local-(docker)-meemaesh3k

And this is docker-compose.yml

version: '3'
services:
  prisma:
    image: prismagraphql/prisma:1.11
    restart: always
    ports:
    - "4466:4466"
    environment:
      PRISMA_CONFIG: |
        port: 4466
        # uncomment the next line and provide the env var PRISMA_MANAGEMENT_API_SECRET=my-secret to activate cluster security
        # managementApiSecret: my-secret
        databases:
          default:
            connector: postgres
            host: localhost
            port: '5432'
            database: databasename
            schema: public
            user: postgres
            password: root
            migrations: true

What am I missing?

Nomura Nori
  • 4,689
  • 8
  • 47
  • 85

3 Answers3

9

I found this solution to the same problem i was facing

docker-machine ip default

Use this address and replace the "localhost" with the IP with the above command to look something like this in prisma.yml file

endpoint: http://1xx.1xx.xx.xxx:4466

The answer is referred from this Github Link

kaushalop
  • 858
  • 9
  • 14
  • I get this output: "Docker machine "default" does not exist. Use "docker-machine ls" to list machines. Use "docker-machine create" to add a new one." How to create a docker-machine? – kwoxer Oct 22 '19 at 06:09
  • @kwoxer try this command: `docker-machine create default`. You can read more here: https://docs.docker.com/machine/get-started/ – Stephen Burke Nov 01 '19 at 20:18
  • I'm now using mongo as docker service. So my issue is now gone. – kwoxer Nov 04 '19 at 07:07
  • 1
    Said process worked for me. The only difference was I had to run `docker-machine ls` to get the ip. – Sunny Prakash May 19 '20 at 15:31
1

The documentation mentions:

docker ps

You should see output similar to this:

$ docker ps
CONTAINER ID        IMAGE                               COMMAND                  CREATED             STATUS              PORTS                    NAMES
2b799c529e73        prismagraphql/prisma:1.7            "/bin/sh -c /app/sta…"   17 hours ago        Up 7 hours          0.0.0.0:4466->4466/tcp   myapp_prisma_1
757dfba212f7        mysql:5.7                           "docker-entrypoint.s…"   17 hours ago  

(Here shown with mysql, but valid with postgresql too)

The point is: there should be two containers running, not one.

Check docker-compose logs to see why the second one (database) did not start.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Thanks, I am running postgresql in my local, in this case how to set prisma to use hosted server's local database? – Nomura Nori Jul 14 '18 at 13:32
  • @NomuraNori Considering prisma is isolated in container, I am not sure it would be able to access a service (like postgresql) running on the local host. – VonC Jul 14 '18 at 13:33
1

instead of docker-compose up -d USE:

docker-compose up

and keep the window running which will keep localhost:4466 alive.

Note : If u want to connect to connect to the database created in docker, you need to map the port in the following way:

docker run --name <ENTER_NAME> -e POSTGRES_PASSWORD=<ENTER_PASSWORD> -d -p 5433:5432 postgres  

In the above case PORT(5433) = HOST_PORT and PORT(5432) = CONTAINER_PORT

код е
  • 196
  • 2
  • 11