2

I have installed PostgreSQL 9.4.6 in docker image with docker version 1.10.1. According to this official image: https://github.com/docker-library/postgres/blob/443c7947d548b1c607e06f7a75ca475de7ff3284/9.4/Dockerfile As it is said here , that to create initial databases I add my sql script in "/docker-entrypoint-initdb.d" . https://hub.docker.com/_/postgres/ Now after having some trouble I found that when I add query to create a database in sql script where database name has '-' ,they just cause the container to crash(i.e. the containers exits just after starting). But query with having no '-' in database name works fine and container also doesn't crash and i can access those database. For example, This query runs fine.

create database 1stName_2ndName with owner vagrant;

But I tried both of this queries individually and it fails for both cases

create database '1stName-2ndName' with owner vagrant;

or

create database 1stName-2ndName with owner vagrant;

Note: consider queries without double-quotation. vagrant user is already created and works fine.

I have a database which name is 1stName-2ndName. Can anybody help me to figure out the issue?

1
  • When I add the sql query in the sql file ...where the database name has '-' (Hyphen) ..the docker container exits just after starting. But when I erase the '-' (Hyphen) from database name in the sql file ...then the container runs fine and I can access and see the databases inside container using docker exec. And actually the last two query are same . I just meant that ..I tried both ways. I will try to escape the DB name with " and `` and let you know. Commented Feb 24, 2016 at 10:29

1 Answer 1

1

At my local Postgres installation, the following query works without a problem:

create database "1stName-2ndName" with owner vagrant;
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.