Creating a domain using rhc
In the Creating OpenShift domains using the web console recipe of Chapter 1, Getting Started with OpenShift, you learned how to create a domain using the web console. In this recipe, you will learn how to create a domain using the rhc command line.
Getting ready
To complete this recipe, you will need to have rhc installed on your machine. Please refer to the Installing the OpenShift rhc command-line client recipe in Chapter 1, Getting Started with OpenShift, for instructions. If you are using OpenShift's free plan, you have to first delete the domain you created in the Creating OpenShift domains using the web console recipe of Chapter 1, Getting Started with OpenShift, before continuing with this recipe. This is required because you cannot have more than one domain with OpenShift's free plan. To delete a domain, run the command shown as follows. This command is explained in the Deleting a domain using rhc recipe in this chapter:
$ rhc delete-domain <domain_name> --force
How to do it…
To create a domain name, open a new command-line terminal and run the following command. Please provide a unique domain name.
$ rhc create-domain --namespace <unique_domain_ame>
Note
If you get the You may not have more than 1 domain
error when you run this command, delete the existing domain associated with your account. In the free tier, you cannot create more than one domain.
How it works…
You can use the rhc domain-create
or rhc create-domain
command to create a new domain name. The only required argument to create a domain is a unique alphanumeric name. Please note that a domain can contain, at most, 16 alphanumeric characters and cannot have spaces or symbols.
The output of the rhc create-domain
command is shown as follows:
$ rhc create-domain --namespace osbook Creating domain 'osbook' ... done You may now create an application using the 'rhc create-app' command
You can avoid using the --namespace
option by typing the following command. The rhc
command-line client is intelligent and understands that you are only providing the mandatory argument:
$ rhc domain-create osbook
There's more...
All OpenShift commands have help associated with them. To understand the usage of the rhc create-domain
command and all the options available with it, you can use the -h
or --help
option. We will look at the other options in the later recipes.
$ rhc create-domain --help Usage: rhc domain-create <namespace>
See also
- The Creating OpenShift domains using the web console recipe in Chapter 1, Getting Started with OpenShift
- The Renaming a domain using rhc recipe
- The Viewing domain details using rhc recipe
- The Deleting a domain using rhc recipe