Is migration from docker to vm possible? - virtual-machine

How to migrate from docker container to virtual machine ? Can somebody give links if any ?

vagrant up
sudo apt-get install lxc-docker
docker import ...
I'm being serious here. This is the whole fun of Docker!

If you mean migrating the services running in docker container to a VM, you could use the Dockerfile as an installation script base.

Related

How to identify whether a linux VM is running on hyper-v environment?

I want to know if the linux VM is running on Hyper-V environment. Is there any way I can identify? Thank you !
It can be determined by installing virt-what
here is documentation
https://linux.die.net/man/1/virt-what
as an example, install on ubuntu:
sudo apt install virt-what
usage:
sudo virt-what

How to install MSSQL-Server on Ubuntu 22.04

I am trying to install MSSQL-Server on my Ubuntu 22.04. I know that it does not currently support Ubuntu 22.04. I need to find a workaround to install the software as I don't want to downgrade.
I tried installing but it keeps giving me dependency errors. How do I solve it? Any help would be appreciated.
Unfortunately, at this time, SQL Server 2019 only works on Ubuntu 20/21. 22.04 is not supported at this time.
So either you will have to use Ubuntu 20 or, as others have stated, use Docker Containers.
You can install Docker into Ubuntu 22.04. It's a multi-step process, but it isn't that difficult.
Install Docker Engine on Ubuntu (follow the Install using the repository section)
https://docs.docker.com/engine/install/ubuntu/#set-up-the-repository
Install SQL Server Container
https://learn.microsoft.com/en-us/sql/linux/quickstart-install-connect-docker?view=sql-server-ver15&pivots=cs1-bash
That should do it.
Also, in link #2, read further below on how to connect to your docker image to run SQLCMD from within the container.
Like SQL Server 2019, you cannot install the SQLCMD tools directly into your Ubuntu 22.04 installation. But the Docker container image contains the sqlcmd tool for you to be able to connect to the database.
Or, you can use Visual Studio Code with the SQL Server (mssql) extension and it can connect to your SQL Server instance in your running Docker container.
The connection string would be:
"Server=localhost;Database=your database name;User Id=user id;Password=password"
You can leave out the Database setting if you just want to connect to the default database.
If you create any databases, you can then connect to them directly by specifying the name.
I also have same problem like this. I also tried downgrading Openssl to 1.1.1k and 1.1.1s but still not works. And finally I found this explanation
https://github.com/microsoft/msphpsql/issues/1419#issuecomment-1303626500
So, keep use OpenSSL 3.0.2 and you just need to change the SECLEVEL to 0 instead of 1 in /etc/ssl/openssl.conf
[system_default_sect]
CipherString = DEFAULT:#SECLEVEL=0
And it works, now I can connect to SQL Server using Ubuntu 22.04.
Looked at this
and it has worked for me!
So worth giving it a shot
cd /opt/mssql/lib
ls -la
sudo rm libcrypto.so libssl.so
sudo ln -s /usr/lib/x86_64-linux-gnu/libcrypto.so.1.1 libcrypto.so
sudo ln -s /usr/lib/x86_64-linux-gnu/libssl.so.1.1 libssl.1.1
If libssl is not installed, try:
sudo apt install libssl1.1
Update: I had issues connecting using libssl1.1, so I switched to 1.0 after performing the previous steps, so I also did the following:
sudo systemctl stop mssql-server
sudo systemctl edit mssql-server
Added:
[Service]
Environment="LD_LIBRARY_PATH=/opt/mssql/lib"
Then:
sudo ln -s /usr/lib/x86_64-linux-gnu/libssl.so.1.0.0 /opt/mssql/lib/libssl.so
sudo ln -s /usr/lib/x86_64-linux-gnu/libcrypto.so.1.0.0 /opt/mssql/lib/libcrypto.so
Then started mysql-server and things just worked fine!

Terraform: How to automate pulling and running docker images from Azure Container Registry

I want to automate the process of pulling docker images from Azure container Registry to the Azure VM. I have already done the following:
Created an Azure container Registry.
Setup username and password in the Azure Container Registry.
Pushed the image from my local machine to the Container Registry.
I have setup up terraform code to automate the build out of Azure VM. I also want to include the docker pull and docker run commands so that those tasks are automated. Below are the commands I would like to automate into terraform:
sudo docker login --username xxx --password xxx xxx.azurecr.io
sudo docker pull xxx.azurecr.io/xx/xxx
sudo docker run --network=host xxx.azurecr.io/xxx/xxx
Any help would be much appreciated. Thank you folks!
As I know, if you want to execute the Docker CLI command in the VM, you should install the Docker engine first.
In addition, if you want to run the Docker CLI commands in the VM automated after creating the VM through Terraform, You can use VM extension in Terraform. Write a shell script with the commands and then run it in the VM extension. Here is the example that Using Terraform with Azure VM Extensions.

Create Docker image from existing Ubuntu + App

I installed Moodle (eLearning PHP based app, but it could be any app) locally on Ubuntu and would like to package it as Docker image/container. There were whole bunch of installations and configurations done. I'd like to package all that so that I can deploy to some Docker enabled hosting service, such as Digital Ocean or AWS.
How do I create Docker image?
Do I need to handle networking, ports and Apache configuration for production deployment?
There ara a lot of Moodle images in dockerhub. just use one of them
The process to create docker images is well documented on Docker's documentation site. See: Build your own images
The idea is simple: You inherit/extend an existing image and make additions to it. This is done in a provisioning file called Dockerfile
Dockerfile Example:
FROM debian:8.4
MAINTAINER John Doe (j.doe#example.com)
# update aptitude
RUN apt-get clean && apt-get update
# utilities
RUN apt-get -y install vim git php5.6 apache2
In the example above I extend a Debian image, update aptitude and install a series of packages.
A full list of commands available in Dockerfiles is available at https://docs.docker.com/engine/reference/builder/
Once your Dockerfile is ready you can build the image using the following command:
docker build -t debian/enhanced:8.4 /path/to/Dockerfile

start redis-server on debian/ubuntu boot

I am trying to create a docker container where redis starts at boot.
there will be other foreground services running on that other container which will connect to the redis db.
for some reason the service does not start when i run the container.
here my simplified Dockerfile
FROM debian
# this solves an issue described here:
# http://askubuntu.com/questions/365911/why-the-services-do-not-start-at-installation
RUN sed -i -e s/101/0/g /usr/sbin/policy-rc.d
# install redis-server
RUN apt-get update && apt-get install -y redis-server
# updates init script (redundant)
RUN update-rc.d redis-server defaults
# ping google to keep the container running in foreground
CMD ["ping", "google.com"]
can anybody explain me why this is not working and how this should be done right?
So a docker container is like a full OS but has some key differences. It's not going to run a full init system. It's designed and intended to run a single process tree. While you can run a supervisor such as runit et al within a container, you are really working against the grain of docker and all the tooling and documentation is going to lead you away from using containers like VMs and toward the harmony of 1 process/service per container.
So redis isn't starting because the ping command is literally the only process running in your container.
there will be other foreground services running on that other container which will connect to the redis db.
Don't do it this way. Really. Everything will be easier when you put 1 process in each container and connect them via network links.
Digging up an old question here, but I landed on it whilst trying to package a really simple Redis job queue into an existing docker image setup. I needed it to start up on image boot so the app could have access to it. Memory and performance are not a concern in this scenario or an external Redis server would absolutely be the right choice.
Here's what I did in my Dockerfile for a simple NodeJs app to make it work without editing any system files post-install:
RUN apt-get update && apt-get -y redis-server
CMD service redis-server start & node dist/src/main
Sort of crude using parallel command processes, but as the accepted answer points out this is not a real operating system so we really only care about Redis being online when the app is.