User could use the following asadmin create-domain command to create a domain1 with saved credential.

$GF_INSTALL/bin/asadmin create-domain –user admin –adminport 4848 –profile developer –passwordfile mypasswordfile –savemasterpassword=true –savelogin=true domain1

The following files are very important and make sure you don’t delete them.

# ls -lF ~/.asadminpass

-rw——-   1 root    root         110 Apr  3 11:19 //.asadminpass

# ls -lF ~/.asadmintruststore

-rw——-   1 root    root         808 Apr  3 11:19 //.asadmintruststore

# ls -lF /opt/glassfish/domains/domain1/config/admin-keyfile

-rw——-   1 root    root         116 Apr  3 11:19 /opt/glassfish/domains/domain1/config/admin-keyfile

/opt/glassfish/bin/asadmin create-domain

Usage: create-domain [–user admin] [–adminport port_number] [–terse=false] [–echo=false] [–interactive=true] [–domaindir
domain_directory] [–profile profile_name] [–template domain_template]  [–passwordfile filename ] [–instanceport
port_number] [–savemasterpassword=false] [–domainproperties (name=value)[:name=value]*] [–portbase portbase] [–savelogin=false]
[–checkports=true] domain_name

Create domain1

# /opt/glassfish/bin/asadmin create-domain –user admin –adminport 4848 –profile developer –savemasterpassword=true –savelogin=true domain1
Please enter the admin password>
Please enter the admin password again>
Please enter the master password [Enter to accept the default]:>
Please enter the master password again [Enter to accept the default]:>
Using port 4848 for Admin.
Using default port 8080 for HTTP Instance.
Using default port 7676 for JMS.
Using default port 3700 for IIOP.
Using default port 8181 for HTTP_SSL.
Using default port 3820 for IIOP_SSL.
Using default port 3920 for IIOP_MUTUALAUTH.
Using default port 8686 for JMX_ADMIN.
Domain being created with profile:developer, as specified on command line or environment.
Security Store uses: JKS
Domain domain1 created.
Login information relevant to admin user name [admin] for this domain [domain1] stored at [/.asadminpass] successfully.
Make sure that this file remains protected. Information stored in this
file will be used by asadmin commands to manage this domain.

Start domain1

# /opt/glassfish/bin/asadmin start-domain domain1

Starting Domain domain1, please wait.
Log redirected to /opt/glassfish/domains/domain1/logs/server.log.
Redirecting output to /opt/glassfish/domains/domain1/logs/server.log
Domain domain1 is ready to receive client requests. Additional services
are being started in background.
Domain [domain1] is running [Sun Java System Application Server 9.1.1
(build b14-fcs)] with its configuration and logs at:
Admin Console is available at [http://localhost:4848].
Use the same port [4848] for “asadmin” commands.
User web applications are available at these URLs:
[http://localhost:8080 https://localhost:8181 ].
Following web-contexts are available:
[/web1  /__wstx-services ].
Standard JMX Clients (like JConsole) can connect to JMXServiceURL:
[service:jmx:rmi:///jndi/rmi://localhost:8686/jmxrmi] for domain management purposes.
Domain listens on at least following ports for connections: [8080 8181 4848 3700 3820 3920 8686 ].
Domain does not support application server clusters and other standalone instances.



Hope this information helps.