-
Notifications
You must be signed in to change notification settings - Fork 0
2.4 Building and Running
Both main and stepup site would build (if required) and run the Docker
containers through the Docker Compose tool. We need to ssh
into each guest VM separately.
The command differ when accessing the virtual machines when they are hosted locally on VirtualBox and remotely in the cloud on AWS.
$ vagrant ssh main
$ cd /vagrant
$ docker compose up
$ vagrant ssh stepup
$ cd /vagrant
$ docker compose up
Assuming the AWS CLI is installed, run the following command:
$ aws ec2 create-key-pair \
--key-name my-key-pair \
--key-type rsa \
--key-format pem \
--query "KeyMaterial" \
--output text > $HOME/.ssh/id_rsa.pem
Private key pair is stored in id_rsa.pem
. Now we need to extract the public
key used for creating the EC2 instances. The private key is used for
logging in to the virtual machine instances later.
$ ssh-keygen -y -f $HOME/.ssh/id_rsa.pem > $HOME/.ssh/id_rsa.pub
Now, public key is stored in id_rsa.pub
.
Tip
There are other methods for generating your SSH key pair. Kindly refer to create key pairs for more information.
Tip
The log in user name for the AWS EC2 instance may need to be adjusted to
ec2-users
if a non-Ubuntu AMI is used. See:
managing users.
$ ssh -i $HOME/.ssh/id_rsa.pem ubuntu@<main-instance-public-dns-name>
$ git clone --depth 1 https://github.com/gyk4j/toc.git
$ cd toc
$ docker compose up
$ ssh -i $HOME/.ssh/id_rsa.pem ubuntu@<stepup-instance-public-dns-name>
$ git clone --depth 1 https://github.com/gyk4j/toc.git
$ cd toc
$ docker compose up
Tip
We may also split the action of building and running the Docker containers by using the following commands instead:
$ docker compose build
$ docker compose up
Copyright © 2024 gyk4j. All rights reserved.